/ Published in: PHP

Add an ID to the body tag.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $body_id =""; if ( is_single() || is_page() ) { $body_id = ' id="'.$post->post_name.'" '; } else if ( is_category() ) { $category = get_the_category(); $body_id = ' id="category_'.$category[0]->category_nicename.'" '; } ?> <body <?php body_class(); ?> <?php echo $body_id; ?> >
Comments
