How to Add Page Slug in Body Class of your WordPress Themes


How to Add Page Slug in Body Class of your WordPress Themes
Lora Joseph

As we know that many times,we need to get the search post by title only .Actually we need the exact and accuracy result in our search functionality. Why would you want to do that? Actually every user’s (Approximately) need the only desire result…

How to Set a WordPress Body Class Using a Page Slug
Dwayne Young

//Body Class for Page Slug
function add_slug_body_class( $classes ) {
if (is_single() ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . ‘-slug-‘ . $post->post_name;
}
return $classes;
}
}
add_filter( ‘body_class’, ‘add_slug_body_class’ );

Be the first to comment

Leave a Reply

Your email address will not be published.


*