Support » Fixing WordPress » Include parent page when listings child pages with wp_list_pages?

  • Sorry if this is a stupid question but I can’t figure this out…

    How can I modify this code to include the parent page as well ?

    <?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?>

    I’m after something more like this:

    <li>Link to Parent page</li>
    <li>Link to sub page</li>
    <li>Link to sub page</li>

    Any thoughts much appreciated. Thankyou.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I couldn’t find a clean way to write this, but the below seems to be working ok:

    <?php
    $current = getcwd();
    if ( is_page('Services') ) { $current = '<li class="page_item current_page_item"><a href="services/">Services</a></li>'; }
    else $current = '<li><a href="services/">Services</a></li>';
    ?>
    <?php echo $current; ?>
    <?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id);
    ?>

    Not bad for a non programmer!

    See this post for a plug-in that does it for you, I use it and it works perfectly.

    Cheers,
    Michael.

    There’s quite a few plugins mentioned there, could you tell me which one worked for you?

    Cheers J.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Include parent page when listings child pages with wp_list_pages?’ is closed to new replies.