WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show parent page as a link with sub pages in sidebar (1 post)

  1. ke vinritt
    Member
    Posted 3 years ago #

    Currently my sidebars (here's an example) list the sub pages of the parent that they're on. However, is there a way to have the parent page listed as a link with the sub pages? So for the link above, the link to the Academy main page would be included above the sub page 'Life at MCA'. I know I can add the title but I want a link that insertes into the list of sub pages.
    Here's the code I have for the sub pages

    <?php
    $output = wp_list_pages('echo=0&depth=1&title_li=' );
    if (is_page( )) {
      $page = $post->ID;
      if ($post->post_parent) {
        $page = $post->post_parent;
      }
      $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
      if ($children) {
        $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=');
      }
    }
    echo $output;
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.