Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Adds classes for custom post types to body_class() and post_class()
- function fb_add_body_class( $class ) {
- $post_type = 'my_example_post_type'; // the Post Type
- if ( get_query_var('post_type') === $post_type ) { // only, if post type is active
- $class[] = $post_type;
- $class[] = 'type-' . $post_type;
- }
- return $class;
- }
- add_filter( 'body_class', 'fb_add_body_class' );
- or
- add_filter( 'post_class', 'fb_add_body_class' );
- Example: <div <?php post_class('class-name'); ?>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement