Support » Fixing WordPress » Show only the categories tied to a Single post

  • On the homepage I am showing Posts previews. I only want to show the Featured Image, Title with permalink, and the Category of the State the post is tied to. So that when someone clicks on the state category link, they see all the other posts tagged in the same state category.

    The problem I am having is making only that one state show up for that post. Right now all states categories that have a post tied to them are showing up under each post. Its essentially just showing the entire subcategory.

    I need to make it only show the one state that that post is tagged in. Here’s the code I currently have. What other argument do I need to make it work the way I want?

    <?php wp_list_categories('style=none&orderby=id&use_desc_for_title=0&child_of=6'); ?>

    And when I say State, I mean of the 50 States of the USA.

Viewing 1 replies (of 1 total)
  • Ok, figured out that I need to use get_the_category instead. But need to put in a parent category. How does this ‘category_parent‘ get inserted into this:

    $category = get_the_category();
    echo '<a>term_id ).'">'.$category[0]->cat_name.'</a>';
Viewing 1 replies (of 1 total)
  • The topic ‘Show only the categories tied to a Single post’ is closed to new replies.