Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1909

    about the sidebar subpages widget , it lists all subpages of the current parent page , currently it looks like this on parent page sidebar

    Parent Page

    Sub Page 1

    Sub Page 2

    Sub Page 3

    and on subpages it looks like this

    Sub Page 1

    Sub Page 2

    Sub Page 3

    whereas i want the subpages to also show the parent page like this

    Parent Page

    Sub Page 1

    Sub Page 2

    Sub Page 3

    i tried searching on net , and came to this conclusion that somewhere this code has to be edited

    <?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) { ?>

    <div class=”widget widget_pages”>

    <h3>Sub-Navigation</h3>

      <?php echo $children; ?>

    </div>

    <?php }

    #36218

    Replace the code you posted above with:

    <?php
    if($post->post_parent) {
    $parent_id = $post->post_parent;
    $children = '<li><a href="'.get_page_link($parent_id).'">'.get_the_title($parent_id).'</a></li>';
    $children .= wp_list_pages("title_li=&sort_column=menu_order&child_of=".$parent_id."&echo=0");
    } else {
    $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0"); }
    if ($children) { ?>
    <div class="widget widget_pages">

    <h3>Sub-Navigation</h3>
    <ul>
    <?php
    echo $children; ?>
    </ul>
    </div>
    <?php }

    #36219

    Which file did you edit?

    #36220

    She modified sidebar.php

    #36221

    Is there a way to only display the child pages of the active parent page, so the menu isn’t so long or if the parent pages that you’re not navigating in collapse?

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

The topic ‘Sidebar Subpages’ is closed to new replies.