WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to display content depending on if a user is in a category or a single post.

The function i'm using if this is a category is:

<?php if (is_category('')) { ?>

Similarly the function i'm using if this is a single post is:

<?php } elseif (is_single($post)) { ?>

How can I join these 2 functions creating a single function call to say if this is any category OR any single post?

share|improve this question

If this is the same if/else, you can just combine into if ( is_category() || is_single() ). You don't need to pass anything to is_category() or is_single() most of the time, unless you are looking for a category or post in particular.

share|improve this answer
Exactly right. if ( is_category() || is_single() ) will return true if the current page is a Category Archive Index or a Single Blog Post. – Chip Bennett Jun 28 '11 at 0:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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