WordPress.org

Ready to get started?Download WordPress

Forums

How can I list categories hierarcical for a post? (3 posts)

  1. spstieng
    Member
    Posted 5 years ago #

    I have a post which is related to 3 categories, top level category, city and street.

    I want to display the categories in the following order: City > Street (excluding top category)

    The following code displays the categories in alphabetical order:

    foreach((get_the_category()) as $category) {
        echo $category->cat_name . ' >';
    }

    The function get_the_category has no means of displaying it parent / child order.

    So how can I display the categories in parent / child order like wp list categories ?

    PS. No, I can't use wp_list_categories() because it has no relation the the post and lists all parent / child categories.

    Any help appreciated.

  2. spstieng
    Member
    Posted 5 years ago #

    Looks like 2.6 bugs are dominating this forum right now. But I'll bump this question anyway :)

    Is the solution for my problem to do a direct query to the database?

  3. Tom(dB)
    Member
    Posted 5 years ago #

    yes, this issue has been present for some time now, and is most annoying.I have as yet not figured a fix. I think it's up to the WP team to sort out.

Topic Closed

This topic has been closed to new replies.

About this Topic