[wp-trac] [WordPress Trac] #11026: wp_list_pages include and depth argument conflict

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 24 21:19:48 UTC 2009


#11026: wp_list_pages include and depth argument conflict
--------------------------+-------------------------------------------------
 Reporter:  pnts          |       Owner:  pnts                     
     Type:  defect (bug)  |      Status:  new                      
 Priority:  normal        |   Milestone:  2.9                      
Component:  Template      |     Version:  2.8.5                    
 Severity:  normal        |    Keywords:  needs-patch wp_list_pages
--------------------------+-------------------------------------------------
Changes (by filosofo):

  * keywords:  needs-patch => needs-patch wp_list_pages


Comment:

 Replying to [ticket:11026 pnts]:
 > So, in this example, I have a large number of top-level pages, and I
 just want to include 4 pages, plus their children, in my global
 navigation, I'd use:
 >
 > {{{
 > <?php wp_list_pages('title_li=&depth=2&include=12,26,22,47); ?>
 > }}}

 Unfortunately, that's not what "include" means.  "include" specifies which
 IDs to show.  What you're looking for is something like "include_tree",
 which doesn't yet exist as an option.  See #9232, a ticket proposing this
 enhancement.

 One simple way to do this is hard-code the list elements of pages 12, 26,
 22, and 47, and within each list item call {{{wp_list_pages()}}} each call
 specifying that page in the "child_of" parameter.

 E.g:

 {{{
 <ul>
    <?php foreach( array(12,26,22,47) as $page_id ) : ?>
    <li class="page_item page-item-<?php echo $page_id; ?>">
       <a title="<?php echo esc_attr(get_the_title($page_id)); ?>"
 href="<?php echo get_permalink($page_id); ?>"><?php echo
 get_the_title($page_id); ?></a>
       <ul>
       <?php wp_list_pages('title_li=&depth=2&child_of=' . $page_id); ?>
       </ul>
    </li>
    <?php endforeach; ?>
 </ul>

 }}}

 This ticket should probably be closed as a duplicate of #9232.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11026#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list