WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to NOT list child pages in wp_list_pages()

[Resolved] How to NOT list child pages in wp_list_pages()

  • Hi,

    I’m trying to disable listing child-pages in wp_list_pages() for the header of my site. I’m using the Corodobo Green Park theme. The section of code with this in it is:

    <div id="single_post_right">
    	<div id="single_post_left">
    		<ul id="navlist"><li class="page_item"><a href="<?php bloginfo('url'); ?>">Home</a></li><?php wp_list_pages('title_li='); ?></ul>
    	</div>
    </div>

    Anyway, I know I can manually disable specific pages, but I’d like the process to be dynamic so I don’t have to edit the template for every new child.

    What can I do?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Add the depth=-1 parameter.

    See:
    Template_Tags/wp_list_pages

    Awesome, thanks!

    depth=-1 didn’t actually work (didn’t seem to do anything, actually). I had to use depth=1.

    I ended up with this:

    <div id="single_post_right">
    	<div id="single_post_left">
    		<ul id="navlist"><li class="page_item"><a href="<?php bloginfo('url'); ?>">Home</a></li><?php wp_list_pages('title_li=&depth=1'); ?></ul>
    	</div>
    </div>

    Good catch. -1 means show pages and child pages in a flat (no indent) format.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] How to NOT list child pages in wp_list_pages()’ is closed to new replies.
Skip to toolbar