WordPress.org

Ready to get started?Download WordPress

Forums

if in category (9 posts)

  1. 5115
    Member
    Posted 6 years ago #

    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.

  2. 5115
    Member
    Posted 6 years ago #

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

  3. 5115
    Member
    Posted 6 years ago #

    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.

  4. 5115
    Member
    Posted 6 years ago #

    Nobody?

  5. 5115
    Member
    Posted 6 years ago #

    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.

  6. whooami
    Member
    Posted 6 years ago #

    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.

  7. 5115
    Member
    Posted 6 years ago #

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

  8. whooami
    Member
    Posted 6 years ago #

    why do you need another tag?

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

    see the ! ???

  9. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags