WordPress.org

Ready to get started?Download WordPress

Forums

Trouble with depth using wp_list_categories (3 posts)

  1. Nugerama
    Member
    Posted 3 years ago #

    Hi, I really hope someone can help me. I'm using wp_list_categories to, well, list some categories in my footer. The arguments for 'include' and 'depth' work independently of one another but now when used together:

    <?php wp_list_categories('title_li=&include=3,773,789,849,882&depth=0'); ?>

    I just get the top level as if I specified 'depth=1', same if I up the depth to 2 or 3. Can these not be used in conjunction? Any ideas very welcome.

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    The include argument is basically a white-list. The output of wp_list_categories() will include only the Pages you list with the include argument, regardless of your depth argument.

    Perhaps try using exclude to exclude the Pages you don't want, instead of using include to include the Pages you do want?

    Note, you could also use exclude_tree, though, last I checked, its behavior could be a bit... non-intuitive.

  3. Nugerama
    Member
    Posted 3 years ago #

    Brilliant! So so much for the speedy reply chip - seems so obvious now you've pointed it out!

    I've opted to exclude rather than include and it's working a treat. Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic