Support » Developing with WordPress » Listing Subcats on a Category Page

  • Resolved elevenmedia


    I am a php newbee. I am tring to get a list of Child Categories listed on a Category page. If I have a Category called ‘Books’ I want it to write the Subcats of ‘Books’ on the page. I have the below code that gets me the category number and writes it .. which i dont need.

    I want the wp_list_categories to only list the children of the category they are in

    $cat = get_the_category(); $cat = $cat[0]; echo $cat->category_parent;
Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH


    Seems all you would need would be:

    <?php wp_list_categories('child_of=21'); ?>



    I need it to be dynamic, so that if populates the ‘child_of=’ by figuring out what the parent is first


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Listing Subcats on a Category Page’ is closed to new replies.