Posted By

creator on 12/01/08


Tagged

wordpress category


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

nerdfiles
SmpleJohn
rickfu
bryandease
LeslieOA
marclarr
fyreflyX
lromak
dato


WordPress: If In Category


 / Published in: PHP
 

For use on a single page... Only displays the content if the displayed post is in the specified category. You can use the category slug or the category ID if you know it.

  1. <?php if (in_category('events')) : ?>
  2. <div class='eventinfo'>
  3. <h2>Event Details</h2>
  4. <?php the_meta(); ?>
  5. </div>
  6. <?php endif; ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: DanielPaul on August 13, 2010

Thanks! Very useful.

Posted By: sagive on July 23, 2011

Great but.. what if i want the condition to include all categories ? Meaning to check if i am in a category "page"

Posted By: sagive on July 23, 2011

Great but.. what if i want the condition to include all categories ? Meaning to check if i am in a category "page"

You need to login to post a comment.