I'm trying to build a list of the first subpage out of 10 pages.
So my page structure is this:
- Page A
- Page A1
- Page A2
- Page B
- Page B1
- Page C
- Page C1
- Page C2
- Page C3
And I'd like to display this list in my template:
- Page A1
- Page B1
- Page C1
I'm pretty close, but I'm stuck on a bug in WP_List_pages that causes the number parameter to not work (http://core.trac.wordpress.org/ticket/10745). This means all the subpages are always displayed, whereas I only want to display the first subpage. This is the code I'm using:
<?php
$args=array(
'post_type' =>'page',
'showposts' =>10
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) { ?>
<ul>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
$children = wp_list_pages('title_li=&child_of='.$id.'&echo=0');
$pieces = explode('"', $children);
<-- STUFF GOES HERE? -->
?>
<?php endwhile; ?>
</ul>
<?php } //if ($my_query)
wp_reset_query(); // Restore global post data stomped by the_post(). ?>
I'm thinking I'll need a for loop to only display the first post, but my php knowledge is lacking so I'm kind of stuck. Anybody in for a quick answer?