WordPress.org

Ready to get started?Download WordPress

Forums

child_of not working with wp_list_categories (3 posts)

  1. bsytko
    Member
    Posted 2 years ago #

    Hi all,

    I have a list of categories that includes several sub-categories in the tree. When I use the wp_list_categories function to print these out, this works perfectly. However, when I add the child_of paramter and pass it a number of the category it just returns 'No categories.'

    $args = array(
         'child_of' => 5,
         'hide_empty' => 0
     );
    
    wp_list_categories($args);

    This returns 'No categories'. But, if I just do:

    wp_list_categories();

    with no arguments, it prints out the tree correctly! Anyone know what I'm doing wrong?

    Thanks!

  2. equalmark
    Member
    Posted 2 years ago #

    By adding child_of you are saying only show categories that are a child of category with the ID 5. Is this correct?

  3. bsytko
    Member
    Posted 2 years ago #

    Yep, I want to show all sub categories of catId=5. They show up fine when I just use the command without any arguments but not when I try to specifically nail it down to 1 category.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.