WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Listing Subcats on a Category Page (3 posts)

  1. elevenmedia
    Member
    Posted 7 years ago #

    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

    <?php
    $cat = get_the_category(); $cat = $cat[0]; echo $cat->category_parent;
    wp_list_categories('child_of=21');
    ?>
  2. MichaelH
    Member
    Posted 7 years ago #

    Seems all you would need would be:

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

  3. elevenmedia
    Member
    Posted 7 years ago #

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

    k

Topic Closed

This topic has been closed to new replies.

About this Topic