Forums

[resolved] Display first level children of parent category in all children level (3 posts)

  1. Suxa23
    Member
    Posted 1 year ago #

    I'm working in my category navigation as a dropdown list. I want to be able to display the children and grandchildren of the parent category. The problem I'm having is that once I'm in the children page, it lists the children of that subcategory if there's any, if not then it will display "No categories." I want to always have the same navigation in all levels, so basically I want the parent's first level children to be listed in all levels.

    The code I'm using is this:
    wp_list_categories('title_li=&order=DESC&child_of='. $cat);

    And it returns this list on parent page:
    Children #1 (1st level)
    Children #2 (1st level)
    - Grandchildren#1 (2nd level)
    --- Grandchildren#1(3th level)
    - Grandchildren#2 (2nd level)
    Children #3 (1st level)
    Children #4 (1st level)

    If I'm in Children #2 (1st level) returns this list:
    Grandchildren#1 (2nd level)
    - Grandchildren#1(3th level)
    Grandchildren#2 (2nd level)

    Then it returns this list on Children #3 (1st level):
    No Categories

    I want to be able to display the list that's on the parent level category in all of its children category.

    Can someone help me out with this, I have looked all around for days and haven't been able to find something that works, some codes out there require the category ID but I want to use this in all of my categories.

  2. Alonce Vincent
    Member
    Posted 1 year ago #

  3. Suxa23
    Member
    Posted 1 year ago #

    The problem with this code is once I go inside a subcategory it will show me that subcategory level of subcategories, and so on until it reaches no categories. Thanks for taking the time to reply.

    Anyways I couldn't find a solution to this, so I had to work around this and limit the allowed number of subcategories per category and their children. I will be closing this post since I'm no longer working on this project.

Topic Closed

This topic has been closed to new replies.

About this Topic