WordPress.org

Ready to get started?Download WordPress

Forums

Display Subcategories of Different Parent Categories of the Same Post (1 post)

  1. Sum1ElsN0tM3
    Member
    Posted 1 year ago #

    By default, displaying categories for the current post, displays ALL categories alphabetically. I want to modify that to show subcategories of a particular parent category and subcategories of another particular parent category, separately. It's not working for me at all.

    Every tutorial that I find shows how to either display all posts of a category or all categories of a post. I hope this is making sense. To explain what I mean, my exact code and the rendered text is below.

    Here are the categories and their IDs, so that you can see what I am doing in the code.
    Counties = 1
    Industries = 60
    Examples = 81

    In the rendered text, "Hardy" is the county assigned to this example post and "Advertising" is the industry. "Example" should not even be displaying.

    The Code:
    <div class="meta">County: <?php the_category('child_of=1&exclude=81') ?> | Industries: <?php the_category('child_of=60&exclude=81') ?></div>

    The Text Rendered on the Page:
    County: Advertisingchild_of=1&exclude=81Exampleschild_of=1&exclude=81Hardy | Industries: Advertisingchild_of=60&exclude=81Exampleschild_of=60&exclude=81Hardy

Topic Closed

This topic has been closed to new replies.

About this Topic