WordPress.org

Ready to get started?Download WordPress

Forums

Styling different categories (1 post)

  1. viktorrichardson
    Member
    Posted 6 years ago #

    Hi,

    I want to have a different background-color on my post depending on what category it is.
    What I need is a variable or funtcion that returns either the catergory ID or the category name of each post. For example the "the_ID()" function returns the post-ID.

    I want to make something like this:
    <?php
    if( the_category_ID() == 2 ) {
    echo "<div class='blue'>"
    }
    ?>

    ...or something like that ;)
    This doesn't work because there is no the_category_ID()-function. Is there a function (or maybe a variable) that i can use?

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 6 years ago by viktorrichardson
  • This topic is not resolved
  • WordPress version: 2.3