If you want to list child categories in custom category template? This piece of code will return you the child categories of a parent.
1 2 3 4 5 | $cat = get_category( get_query_var( 'cat' ) ); $cat_id = $cat->cat_ID; $child_categories=get_categories( array( 'parent' => $cat_id ) ); |
Just pass the category id to $cat_id variable which children you want. After that you can design or print those as you want. Example:
1 2 3 4 | foreach ( $child_categories as $child ) { // Here I'm showing as a list... echo '<li>'.$child ->cat_name.'</li>'; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.