Forums

[resolved] Conditional tags "if category = ..." (4 posts)

  1. robcub
    Member
    Posted 1 year ago #

    I know I've done something stupid with PHP but I just can't get this to work.

    <?php if (is_category('this')) { ?>
    DO THIS
    <?php } elseif (is_category('that')) { ?>
    DO THAT
    <?php } else { } ?>

    This is always returning DO THIS no matter which category the post is in. And no matter whether I try ID numbers or the category slug.

    This is within a loop that is only showing the first post of one of two categories. It starts like this:

    <?php query_posts('showposts=1&cat=3,5');?>
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Any ideas what I'm doing wrong?

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    Try it with: in_category('this')
    Just guessing but give it a shot

  3. robcub
    Member
    Posted 1 year ago #

    That worked!

    keesiemeijer, that's probably the 4th time you've really helped me out. I really appreciate it. I just don't know what to say!

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    No problem. I'm glad you got it working.

Topic Closed

This topic has been closed to new replies.

About this Topic