• Maxaud

    (@maxaud)


    How would I go about showing the categories a post belongs to while excluding certain categories from the list? Is there a different template tag that would work better than the_category?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you find the solution for this issue? Im finding the solution too. Thanks!

    Exclude ONE category by ID (use the_category):
    (Eg: Exclude the Category ID=10)
    <?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID==10)) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. ' - ' . $cat->cat_name . '</a>';} ?>

    Exclude MULTI categories by ID (use the_category):
    (Eg: Exclude 3 Categories ID=10,20,30)
    <?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID=='10' || $cat->cat_ID=='20' || $cat->cat_ID=='30')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. ' - ' . $cat->cat_name . '</a>';} ?>

    It will work for you!

    EXACTLY what i needed.
    Thanks a mil.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘exclude categories by ID in the_category’ is closed to new replies.