Workaround for: IF post IN category-id ? (3 posts)

  1. winpoka
    Posted 10 years ago #

    I've made good use of the available conditional tags however haven't found a way to create something like...

    if (post-in-category-1) show { something-i-want-to-show-in-cat-1-posts-only } else { something-i-want-to-show-in-every-other-post }

    I have two main parts to my blog: a main blog category which I will be adding information to that is available for comment from the general public, and the rest of my categories, which are state indexes, available to comment on only by registered members of that state.

    I'm not an expert at coding but I think I have the jist of it! Any help is much appreciated!

  2. Kafkaesqui

    Posted 10 years ago #


    <?php if(in_category(1)) : ?>
    ~ Do this when post is in category 1 ~
    <?php else : ?>
    ~ Do this the rest of the time ~
    <?php endif; ?>

    Note that in_category() should be used within The Loop.

  3. winpoka
    Posted 10 years ago #

    Thanks so much Kafkaesqui! Worked like a charm. I must've overlooked the power of the in_category tags in the first place!

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic