Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2853

    Hello,

    The parent sidebar display is not showing the complete list of menu pages. Please view: http://www.directskills.com.au/labour-hire-services/building-services/ When Building Projects or Civil Projects is selected (2nd level page) the sidebar menu pages display disappears.

    Please help.

    Thank you,

    Jason

    #39541

    Hey,

    the reason is because the sidebar displays the child pages only. If you’re on the child page there are no other pages to display. The list of pages is generated in sidebar.php by following code:

    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>

    Try to replace it with this code:

    <?php
    $children = wp_list_pages("title_li=&sort_column=menu_order&echo=0");
    if ($children) { ?>

    This should display all pages…

    #39542

    Hello,

    Yes it displays all the pages, however it displays every single page. Only would like it to display the page menu pages.

    Cheers,

    Jason

    #39543

    Try to replace following code in sidebar.php:

    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>

    with:

    <?php
    function get_root_parent($page_id) {
    global $wpdb;
    $parent = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE post_type='page' AND ID = '$page_id'");
    if ($parent == 0) return $page_id;
    else return get_root_parent($parent);
    }

    $root_parent = get_root_parent($post->ID);

    if($root_parent != "")
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$root_parent."&echo=0");
    else if($post->post_parent)
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
    else
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
    <div class="small_box widget_pages">
    <h3>Sub-Navigation</h3>
    <ul>
    <?php echo $children; ?>

    This should display all grandparent children too so I think the code will do what you want…

    #39544

    Hi Dude,

    I’m glad you know what you’re doing. Works perfectly. Thanks mate

    Jason

    #39545

    Glad that I could help you :)

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Parent sidebar display’ is closed to new replies.