Custom Sidebar for Specific Pages (1 post)

  1. martinmich
    Posted 4 years ago #

    I'm giving up.

    I need my sidebar.php file to say if it's page 1,2,3 the sidebar should link to only subpages 6,7,10. If it's anything else, link to everything.

    This is the code for the sidebar right now, it just shows everything on the sidebar. Hope I make sense because I'm exhausted now.

    <div id="sidebar">
    $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&depth=1&child_of=' . $page . '&title_li=' );
      if ($children) {
        $permalink = get_permalink($post->post_parent);
        $thispage = get_permalink();
        $output = wp_list_pages ('echo=0&depth=1&child_of=' . $page . '&title_li=');
      <?php if ($children) { ?>
      <li<?php if ($thispage == $permalink) { ;?> class="current_page_item"<?php } ?>><a>">Overview</a>
      <?php echo $output; ?>
      <?php } ?>
      <?php } ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.