Second Loop in WordPress

Chris — January 13, 2009

Twice today I wanted, tried and failed to create a loop to list all the children pages of the current page in wordpress. Adn yes I know I could use “wp_page_menu” or “wp_list_pages” but the problem is I wanted to include custom fields in the output.

Look at my works page. I wanted each website to be a child page of work and display the content, or a custom field, as an excerpt. And to my knowledge I can’t do that with any of the page list functions. Anyone know how to do this? Making the work pages as posts isn’t really an option.

For my works page I just listed them statically. For the other attempt I had to create a MySQL query against the posts table and manually create the list. Not ideal.

So if anyone sees this and might know a solution, please drop me a line!


  1. Comment by PareUnlal — January 3, 2010 @ 6:06 pm

    What Word Press theme do you use?

  2. Comment by admin — January 4, 2010 @ 9:17 am

    It’s my own. Feel free to jack it, just keep my name and email in the CSS if you use a straight rip of it (if it’s even there?) :)

  3. Comment by Karl — March 29, 2010 @ 7:45 pm

    ‘numberposts’ => -1,
    ‘post_status’ => null,
    ‘post_parent’ => $post->ID, // $post->ID gets the ID of the current page
    ‘order’ => ASC,
    ‘orderby’ => title
    $subpages = get_posts($args);
    // Just another WordPress Loop
    foreach($subpages as $post) :
    <a href=”" id=”post-”>

    works fairly well… its from

  4. Comment by Karl — March 29, 2010 @ 7:47 pm

    sorry first 3.5 lines got cut off they are…

RSS feed for comments on this post. TrackBack URL

Leave a comment