Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
2  
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
add comment

Your Answer

 
discard

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.