Forums

Putting the category ID in the body tag (2 posts)

  1. RolloTamasi
    Member
    Posted 2 years ago #

    Hi guys,
    I'm wondering if it's possible to have the ID (or name) of a category appear within the body tag?

    An example might be <body class="wordpress y2010 m04 d23 h14 cat=22"> where 22 equals to the web design category.

    I'm trying to load in specific theme elements per category using this technique.

    C.

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    <?php if(is_category()) { $cat_ID = 'cat-'.get_query_var('cat'); } ?>
    <body <?php body_class($cat_ID); ?>>

    would add something like 'cat-22' to the other body classes.

    http://codex.wordpress.org/Template_Tags/body_class
    http://www.whypad.com/posts/wordpress-get-category-id-while-on-a-category-page/669/

Topic Closed

This topic has been closed to new replies.

About this Topic