Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i am serching a WP function that controls is there any child category/ies of current category (in category.php outside of the loop) and if there is, just add link list for that category/ies to page, otherwise (there is no child category for current) list all post(s) in this category. Thanks in advance...

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can get the current posts category outside the loop by using the get_the_category function.

When you have the actual category ( however you got it) you can use get_categories, specifically the 'child_of' parameter and pass it the parent cat ID.

Also have a look at wp_list_catagories, where you can do something simple like the following to grab the children.

 <?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=8'); ?>

You would probably do an "if" statement to get the children if they exist and if not just show the category.

share|improve this answer
Thanks, i used get_categories and worked.. – Alper Mar 5 '11 at 17:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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