Forums

[resolved] Body Class theming (4 posts)

  1. FuxiAdmin
    Member
    Posted 2 years ago #

    Hi

    I've changed the theme to one of my categories but the individual 'single' post within that category remain the same as single posts in other categories.

    Please view (category) - http://www.fuximagazine.com/category/television/

    Please view (single) -
    http://www.fuximagazine.com/television/2010/02/27/taken-by-cars-uh-oh/

    I've tried a few codex codes but the only way I have managed to change the theme of invidual posts is through selecting the actual postid.

    Does anybody know a code that can select all post that are under a particular category?

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    as you mentioned 'body_class()' in your title, here is a possibility:

    <?php if(in_category('25')) { $cat_class = 'cat-25'; }; ?>
    <body <?php body_class($cat_class); ?>>

    adjust the number to your category of interest (or use the category slug), and try and use this instead of the <body> tag, probably in header.php.

    http://codex.wordpress.org/Template_Tags/body_class
    http://codex.wordpress.org/Conditional_Tags#A_Category_Page
    http://codex.wordpress.org/Function_Reference/in_category

  3. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    http://codex.wordpress.org/Template_Tags/in_category

    You could use this to add a category=specific class to the body tag in header.php.

    <?php if( in_category('television') ) $xclass = 'tv';
    else $xclass = '';?>
    [...]
    <body <?php body_class($xclass); ?>>
  4. FuxiAdmin
    Member
    Posted 2 years ago #

    Thanks

    esmi, I saw another post where you showed somebody how to add category class to posts. It solved my problem, cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags