WordPress.org

Ready to get started?Download WordPress

Forums

Hierarchical Category Display (6 posts)

  1. greg
    Member
    Posted 9 years ago #

    Hi all, hope somebody can help. Thanks in advance.

    I would like to display under each of my posts a hierarchy of locations, I'm using categories and child categories to record the location.

    Imagine this, I choose all the following categories to record my location in a travelogue:

    -State: Minnesota
    ---County: Hennepin
    ------City: Minneapolis
    -State: Wisconsin
    ---County: Dane
    ------City: Madison

    Does anybody know a good way to set up my category listing to display this with this sort of hierarchical layout.

    Sorry for the kind of incoherent description, like I said, I hope someone can help.

    Cheers.

  2. groovenectar
    Member
    Posted 9 years ago #

    try opening your sidebar template... find where it has the function list_cats(...)

    remove or comment out that function, and replace it with:
    wp_list_cats("children=TRUE&hide_empty=0&optioncount=1&sort_column=name&exclude=12")

  3. greg
    Member
    Posted 9 years ago #

    Wow, well that's beautiful, thank you!

    I was actually hoping to figure out how to do that within the posts themselves, too. To show the locations referred to in each original post... Basically modifying 'the_category' tag, I think.

    Does that make sense?

    Many, many thanks!

  4. Kafkaesqui

    Posted 9 years ago #

    greg: Look at the 'parents' parameter for the_category():

    http://codex.wordpress.org/Template_Tags/the_category

  5. greg
    Member
    Posted 9 years ago #

    UPDATE: scratch this, I'm a moron. All my problems are fixed, thanks again for all the help!

    Again, thank you. That one seems pretty obvious. As a WP newbie, I'm still pretty thrown off by the jargon sometimes and I miss the obvious. One (hopefully final) question:

    I implemented this with 'single' and I now get this for posts with parent categories:

    Minnesota
    Minnesota/Hennepin
    Minnesota/Hennepin/Minneapolis

    Preferably, I'd just like to have

    Minnesota/Hennepin/Minneapolis

    Each term would be a link to the category. Make sense? Possible?

    Thanks for the patient help.

  6. Kafkaesqui

    Posted 9 years ago #

    greg: For what you're trying to do, I think your best option is to use 'multiple' for the 'parent' parameter, and then make sure to select only the child category for a post. Unless you're doing some custom filtering through your templates, WordPress lists posts in a child category under the parent category as well, by default.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags