/add-class-to-single-post.php Secret
Created
December 6, 2013 13:21
Star
You must be signed in to star a gist
[WordPress] If the given post is a single post, then add a class to this post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* If the given post is a single post, then add a class to this post. | |
* | |
* @param array $classes The array of classes being rendered on a single post element. | |
* @return array $classes The array of classes being rendered on a single post element. | |
* @package example | |
* @since 1.0.0 | |
*/ | |
function example_add_post_class_to_single_post( $classes ) { | |
if ( is_single() ) { | |
array_push( $classes, 'single-post' ); | |
} // end if | |
return $classes; | |
} | |
add_filter( 'post_class', 'example_add_post_class_to_single_post' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment