WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to NOT list child pages in wp_list_pages() (4 posts)

  1. Sarkazein
    Member
    Posted 6 years ago #

    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?

  2. MichaelH
    Member
    Posted 6 years ago #

    Add the depth=-1 parameter.

    See:
    Template_Tags/wp_list_pages

  3. Sarkazein
    Member
    Posted 6 years ago #

    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>
  4. MichaelH
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic