WORDPRESS – EASILY LOOP THROUGH PAGE CHILDREN

January 11th, 2009

The following code will let you create a custom “Wordpress Loop” that contains the post objects of the children of the current page.


Just drop this code in your theme file:


<?php
    $project_list = get_posts('numberposts=5&order=ASC&orderby=menu_order&post_type=page&post_parent='.$post->ID);
 
    foreach($project_list as $post):
    setup_postdata($post);
?>
    <div class="post" id="post-<?php the_ID(); ?>">
    </div>
 
<?php 
    endforeach; 
?>