views:

22

answers:

1

Hello all,

I am doing some changes on my blog theme, and i need to list the subcategories when user is inside the parent category, example:

  • main-category -- subcat1 -- subcat2

So i need to show the subcat1 and subcat2 only when the user is inside main-category. At this moment i have 2 divs, one for the main-categories (this is what i need users to see on all pages) and one div bellow the main-category div to show the subcategories.

Is this possible? I am sorry for my English, let me know if this is too confuse.

Thanks for your time. Regards

+1  A: 

Yes, it's possible using get_the_category() and wp_list_categories() with the child_of parameter. Use something like the following on your main-category page:

$category = get_the_category();
wp_list_categories('child_of=' . $category[0]->cat_ID);
Pat