WordPress.org

Ready to get started?Download WordPress

Forums

List main category, and only 1 level of sub categories (2 posts)

  1. jabbamonkey
    Member
    Posted 2 years ago #

    I've been looking around for how to do this, and there seems to be a ton of example on parents and children, but I can't find one that does what I need.

    So, I have categories like...

    Food
    --Videos
    --Restaurants
    --Recipes
    ----Mexican
    ----Italian
    ----America
    Fashion
    --Style
    --Beauty
    ----Hair
    ----Makup
    --Clothing

    If the user is on a top level category page (such as /category/food/) OR if the user is on a sub page (either category/food/recipes/italian or just /category/food/recipes/), then I need to...

      Print the parent category name and link to it.
      List only the first level sub categories.

    So, if the user was on any food page (or sub category page), they would see the menu...

    [link to food page]Food[/]
    Videos
    Restaurants
    Recipes

    See below for where I am at... not really working and I'm sure my code needs to be cleaned up alot ... So far, if I go to the top level page (i.e. /food/), it prints the ENTIRE list of categories and children. On the subcategory pages (i.e. /food/recipes/ or food/recipes/mexican/) it doesn't show anything.

    [code moderated - please use the pastebin]

  2. mukto90
    Member
    Posted 1 year ago #

    I have same problem. Anyone please help..

Topic Closed

This topic has been closed to new replies.

About this Topic