0

I want to show list of the subcategories when you click on the parent category page. I will be really grateful if someone can help me.

1 Answer 1

2

This code checks if you're on a category page, and if so it lists all the categories that are children of the current category.

if (is_category()) {
  $this_category = get_category($cat);
  if (get_category_children($this_category->cat_ID) != "") {
    wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.