• 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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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”)

    Thread Starter greg

    (@greg)

    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!

    greg: Look at the ‘parents’ parameter for the_category():

    https://codex.www.ads-software.com/Template_Tags/the_category

    Thread Starter greg

    (@greg)

    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.

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hierarchical Category Display’ is closed to new replies.