Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm looking for a snippit/function that will list the child pages of a specific page (I guess by page ID) but not necessarily when you are on that page or a child of that page. The parent page (Parents Area) and its child pages are listed below:

Parents Area
- Term Dates
- Calendar
- School Blog
- Letters to Parents
- Attendance

I want to be able to be on any page of the website, specifically within single posts and post archives but be able to list out just the children of the parent page "Parents Area".

share|improve this question
    
Post your code please. –  s_ha_dum Sep 12 '13 at 15:08
    
The code for which part? I don't have any code for this functionality just yet. I've got my code (functions.php) to output my subnav across the rest of the site which works perfectly: pastebin.com/HKeyqjXE I need to do exactly the same thing, but for a specified page ID regardless of what page I'm on. –  user1001657 Sep 13 '13 at 13:32
    
As written, I can't help but consider this "work for me for free". You are expected to have researched the problem and made an attempt at solving it before posting a question. There are a lot of "list child pages" questions to the right under "RELATED". Why don't you try to get yourself started and edit the question so that it addresses some more specific problem that you encounter. –  s_ha_dum Sep 13 '13 at 13:43
    
That's OK, I understand. I'm just not sure where to start on this one. Am I best off amending my code above, or is this a rather long way of doing it just for this task? –  user1001657 Sep 13 '13 at 14:01
    
At least add more detail. What is that structure above? Is that hierarchical pages? Is that particular menu? This may perhaps be related: wordpress.stackexchange.com/q/105495/21376 Or this: wordpress.stackexchange.com/a/100226/21376 –  s_ha_dum Sep 13 '13 at 14:07

2 Answers 2

up vote 1 down vote accepted

To list subpages of a particular page, use wp_list_pages with child_of argument.

$parent_page_id = 42;
wp_list_pages( array(
    'child_of' => $parent_page_id
) );
share|improve this answer
    
Awesome, that was all I needed! Sorry, still learning my way around the WP functions. –  user1001657 Sep 13 '13 at 17:24

Maybe I didn't quite get what was asked for, but what's wrong in using wp_list_pages?

Here is a sample code (which most probably has to be customized and adapted to fit your needs):

<ul>
    <?php
    $args = array(
        'depth' => 1,
        'include' => YOUR PAGE ID HERE,
        'title_li' => '',
    );
    wp_list_pages($args);
    $args['child_of'] = $args['include'];
    unset($args['include']);
    wp_list_pages($args);
    ?>
</ul>

Maybe you have to adapt the HTML list as well, if you want a hierarchical list of two levels etc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.