Support » Fixing WordPress » if in category

  • Is there a way to adjust the following tag:
    <?php if (in_category(4)) continue; ?>

    So that it’s calling the category name instead of its ID?

    Thanks in advance.

Viewing 8 replies - 1 through 8 (of 8 total)
  • How come this does not work?
    <?php if (in_category('category name')) continue; ?>

    I’ve searched the forums and have found similar requests, but the posts are unanswered.

    Does anyone have a clue on how to use this tag so that it’s calling a category name instead of a category ID?
    <?php if (in_category('4')) continue; ?>

    Any help would be appreciated.

    Thanks in advance.

    Nobody?

    Is being able to use a category name instead of ID possible with this tag???

    <?php if (in_category('4')) continue; ?>

    If not, is there an alternative?

    Help please.

    whooami

    (@whooami)

    Member

    instead of bumping this constantly, read the page:

    http://codex.wordpress.org/Template_Tags/in_category

    I believe that answers your question. That template tag uses an ID, NOT A NAME.

    My apologies for the annoyance.
    Could you tell me if there is an alternative tag? I am trying to ignore a particular category.

    whooami

    (@whooami)

    Member

    why do you need another tag?

    <?php if ( !in_category(5))
    	{ echo "we are not in this category"; } ?>

    see the ! ???

    Is being able to use a category name instead of ID possible with this tag???

    No.

    If not, is there an alternative?

    Yes. Use the ID number instead of the name. Just go to the Manage Categories page and get the ID number, then use that instead of trying to use the name.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘if in category’ is closed to new replies.