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)
  • Thread Starter 5115

    (@5115)

    How come this does not work?
    <?php if (in_category('category name')) continue; ?>

    Thread Starter 5115

    (@5115)

    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.

    Thread Starter 5115

    (@5115)

    Nobody?

    Thread Starter 5115

    (@5115)

    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)

    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.

    Thread Starter 5115

    (@5115)

    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)

    why do you need another tag?

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

    see the ! ???

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    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.