In my list of blog posts, I would like to show a div which labels the post as a "Press Release" if the post is tagged with the "Press" category.

I have added the following chunk into my loop:

<?php if (is_category( 'press' )) : ?><div class="category">Press Release</div><?php endif;?>

I have also tried replacing press with the category ID, but neither seem to work. Is this how I should be implementing this?

1 Answer 1


is_category() does this:

(...) Checks if a Category archive page is being displayed. (...)

One line below on the codex page you find:

To test if a post is in a category use in_category().

So just use the latter.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.