Forums

using "if" with category name display (2 posts)

  1. noooneh
    Member
    Posted 9 months ago #

    I want to display a link in every post to the category of this post, I've been able to do this by adding the code

    <?php the_category(', ') ?>

    Now the question is: how can i exclude the "uncategorized" category?

    i figured out if i exclude category_ID of 1 maybe it would be solved. tried this code with no use

    <?php if ( the_category_ID!=1 ) echo the_category(', ') ?>

    is there a simple conditional statement to say: "If the category ID is not 1 display the link"?

  2. alchymyth
    The Sweeper
    Posted 9 months ago #

    <?php if ( !in_category(1) ) the_category(', '); ?>

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

Reply

You must log in to post.

About this Topic