WordPress.org

Ready to get started?Download WordPress

Forums

List Child Pages (6 posts)

  1. mdesilets
    Member
    Posted 6 years ago #

    Hi! I'm finally starting to get my hands around customizing wordpress and i'm having great fun with it.

    I do have one glitch that is driving me batty.

    I'm using the below code to display a sub page navigation element.

    <?php
    global $wp_query;

    if( empty($wp_query->post->post_parent) ) {
    $parent = $wp_query->post->ID;
    } else {
    $parent = $wp_query->post->post_parent;
    }

    wp_list_pages("&sort_column=menu_order&depth=3&title_li=");
    ?>

    It works great on every page I use it on except for one. On that one page, it displays all of the top level pages including the page its on.

    Any suggestions would be greatly appreciated.

    Thx

    Marty

  2. mdesilets
    Member
    Posted 6 years ago #

    I was able to solve it with:

    <?php
    wp_list_pages("child_of=".$post->ID."&sort_column=menu_order&depth=3&title_li=");
    ?>

    but im not sure thats the best solution...

  3. mdesilets
    Member
    Posted 6 years ago #

    This worked even better to suit my needs!

    <?php
        wp_list_pages("child_of=".$post->post_parent."&sort_column=menu_order&depth=3&title_li=");
    
    ?>
  4. mdesilets
    Member
    Posted 6 years ago #

    having a great time having a conversation with myself... ultimately?

    I decided on this... as I dont want the navigation to change when visiting sub pages...

    <?php
    if($post->post_parent == 0)
    {
    wp_list_pages("title_li=&child_of=".$post->ID."&show_date=modified&date_format=$date_format&location=sidebar&sort_column=menu_order");
    }
    else
    {
    wp_list_pages("title_li=&child_of=".$post->post_parent."&show_date=modified&date_format=$date_format&location=sidebar&sort_column=menu_order");
    }
    ?>

    hopefully this will help someone

  5. PaulButler
    Member
    Posted 6 years ago #

    This helped me, thanks.

  6. abelcreative
    Member
    Posted 6 years ago #

    I could use some help with a similiar issue:

    I'm using this in my sidebar:

    if (is_page('about')) {
                 // our about page.
                 echo "<h1>title</h1>
                 <ol><li>Content here</li></ol>";

    I'm wondering if there's a way to write this so that that block of content appears on the about page and any child page of the about (i.e. pages with About marked as a page parent)

Topic Closed

This topic has been closed to new replies.

About this Topic