currently I have 3 parent page types with multiple child pages under each.
Feature
* feat 1
* feat 2
..
Creative
* creat 1
* creat 2
…
Info
* info 1
* info 2
…
I have been successful with pulling the children page content onto the parent page, but now I want to get the children of Feature and Creative onto Creative Parent page.
here is what I am using to get the child pages of Featured parent page.
<div id="folio-menu">
<div class="inner">
<?php
$projectpage = get_pages('child_of=14&sort_column=post_date&sort_order=desc');
$count = 0;
foreach($projectpage as $page)
{
$content = $page->post_content;
if(!$content)
continue;
if ($count == -1)
break;
$count++;
$content = apply_filters('the_content', $content);
?>
<div class="thumb-container">
<div class="thumb"><a href="<?php echo get_permalink($page->ID); ?>"> <?php echo get_image ("thumbnail",1,1,1,$page->ID);?></a>
</div><p class="smalltitle"><?php echo $page->post_title ?></p>
</div>
<?php
}
?>
</div>
I tried to list both parent page id’s in ‘child_of=14,15&…’ but it did not work.
Thanks!
Like AmbitiousAmoeba mentioned, you’ll need to perform a few
get_pages
calls to lookup the pages for each child, merge the results together, and iterate over those results.I worked up an example for you, because it’s fiddly trying to merge arrays when they have matching indexes, the only thing you should need modify are the
child_of
parameters, and of course add back in your surrounding HTML..Updated example
Uses
array_merge
instead, i mistaken thought it wouldn’t work for with numeric keys(it does though, as Rarst kindly pointed out in the comments)..Old example
Might aswell leave the old example in place
Hope that helps…