WordPress: If In Category


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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

You need to login to post a comment.