WordPress.org

Ready to get started?Download WordPress

Forums

Showing Sub Sub nav for current Page (3 posts)

  1. bcreighton
    Member
    Posted 6 years ago #

    Hi,

    I am using an If, Else structure that checks to see if there are subpages for the current page and adds a subnav to my sidebar. I can get it to work perfectly until I click on the third or more level in - then the nav disappears. This is the logic I have:

    <?php if (is_page(9)) { ?>
        <li><a class="current_page_parent" href="/index.php?page_id=9">Who</a>
          <?php } else { ?>
        <li><a href="/index.php?page_id=9">Who</a>
          <?php } ?>
          <!--check for Who (ID = 9) subpages-->
          <?php if (is_page(9) || $post->post_parent=="9") {
    if($post->post_parent)
    $children = wp_list_pages("sort_column=post_date&title_li=&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("sort_column=post_date&title_li=&child_of=".$post->ID."&echo=0");
    if ($children) { ?>
          <ul>
            <?php echo $children; ?>
          </ul>
          <?php } } ?>
        </li>

    Any ideas? Thanks!

  2. bcreighton
    Member
    Posted 6 years ago #

    For example, something like:

    <?php if (is_page(9) || $post->post_parent=="9" || $post->$post->post_parent=="9")

    but obviously the third post part is wrong. just not sure how to write that logic...

  3. bcreighton
    Member
    Posted 6 years ago #

    Or...

    if (is_page(11) || $post->post_parent=="9"|| $post->post_parent->post_parent=="9")

    but that's not right either. bah!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.