WordPress.org

Ready to get started?Download WordPress

Forums

Include parent page when listings child pages with wp_list_pages? (5 posts)

  1. 3stripe
    Member
    Posted 8 years ago #

    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.

  2. 3stripe
    Member
    Posted 8 years ago #

    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!

  3. niziol
    Member
    Posted 8 years ago #

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

    Cheers,
    Michael.

  4. 3stripe
    Member
    Posted 8 years ago #

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

    Cheers J.

  5. niziol
    Member
    Posted 8 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic