WordPress.org

Support

Support » How-To and Troubleshooting » Displaying a different look for a post dependent on Category

Displaying a different look for a post dependent on Category

  • I like the category of each post to define how that post looks. A good example of this is on the ThinkProgress blog: http://thinkprogress.org/

    I’ve tried a couple things, such as:

    <?php if (is_category(‘postrock’)) { ?>
    html to display
    <? } else { ?>
    html to display
    <? } ?>

    But that doesn’t work. I assume because is_category is for IF we’re on the category page for postrock, then display this.. not IF the category assigned to this post is post-rock, then display this.

    I’ve also tried:

    <?php if the_category() == postrock ?>

    But that only prints the category name.

    Any help is MAJORLY appreciated!

Viewing 1 replies (of 1 total)
  • Terry

    @wherewillyoube

    Sorry for the late reply, I was browsing through the forum and found your problem unresolved.

    You can use <?php in_category('ID') ?> or <?php in_category('category-slug') ?> to select the category you would want to 🙂

    For more information on how to use it, refer to this entry in the codex.

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying a different look for a post dependent on Category’ is closed to new replies.
Skip to toolbar