WordPress.org

Forums

Looking for a template that lists child pages once you go to the parent page (9 posts)

  1. jenster81
    Member
    Posted 7 years ago #

    Hi all,

    I have used the Regulus tempalte before and love the way that the child pages to a parent page only show up once you go to the parent page.
    I'm trying to build a photo site for a friend at the moment and need a theme that does this also, so he can have a menu item 'Photos' then when you're on that page a menu comes up in the sidebar which lists all the child pages underneath it.

    Many thanks!
    jeni

  2. cheese apples
    Member
    Posted 7 years ago #

  3. jenster81
    Member
    Posted 7 years ago #

    Hiya,

    This is good for me for a different purpose, but i really want a theme which lists the child pages once you are on the parent page.

    either that or a plugin which allows dropdown menu function but then im not too technical so the suckerfish method or similar may make me out of my depth!
    thanks

  4. educationthemes
    Member
    Posted 7 years ago #

    This code will list the child pages when on a parent page and include the parent page title in h2 tags above the list of child pages. It also display other child pages of a parent page when on a child page.

    <h2>
    
    <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> Pages
    
    </h2>
    
    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    
    <ul>
    <?php echo $children; ?>
    
    </ul>
    
    <?php } ?>

    See it in action here:

    http://www.themes.educationthemes.co.uk/icy-blue/

    The code should go wherever you want to display the list of child pages. In the above example that was in my sidebar.

  5. emberrains
    Member
    Posted 7 years ago #

    Can you put it just any where in the sidebar code?

  6. emberrains
    Member
    Posted 7 years ago #

    Thanks never mind, I did a search a found a plugin called Flexi Pages Widget, it did exactly what I wanted.

  7. jenster81
    Member
    Posted 7 years ago #

    hiya - educationthemes

    do you put this in your sidebar theme editor file or in a text widget box as part of your sidebar?

    sorry for being thick

  8. educationthemes
    Member
    Posted 7 years ago #

    I have put this in my sidebar.php file. Put it in the location that you want the list to appear.

  9. Kim Parsell
    WP Mom
    Posted 6 years ago #

    Hello educationthemes -

    I just tried the code you provided in my sidebar, and am unable to get it to work (WP version 2.6.1).

    Is there something that needs to be updated in order to get this working?

    Thanks in advance!

Topic Closed

This topic has been closed to new replies.

About this Topic