simple dynamic body ID/class
-
In functions.php, I’ve implemented something like this:
function bodystyle() { global $post; $postclass = $post->post_name; if (is_home()) { echo 'id="home"'; } elseif (is_single()) { echo 'id = "single" class="' . $postclass . '"'; } elseif (is_search()) { echo 'id="search"'; } elseif (is_archive()) { echo 'id="archive"'; } elseif (is_page()) { echo 'id="page" class="' . $postclass . '"'; } }
How would I add another conditional (is_category) that returns the name of the category as a class, similar to what I’ve already done for single-posts and pages?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘simple dynamic body ID/class’ is closed to new replies.