WordPress.org

Ready to get started?Download WordPress

Forums

Sub navigation functionality (1 post)

  1. jbiddulph
    Member
    Posted 2 years ago #

    Hi,

    On my site: here

    I would like the subnavigation only to show when a user clicks on the parent that has children, I alo want to show the parent title

    at the moment, my left mavigation shows eveything and when I click on the sub navigation (child) the parent link disapears?!

    <?php
    global $wp_query;
    
    if( empty($wp_query->post->post_parent) ) {
    $parent = $wp_query->post->ID;
    } else {
    $parent = $wp_query->post->post_parent;
    } ?>
    <?php if(wp_list_pages("title_li=&child_of=$parent&echo=0&depth=1" )): ?>
    <div id="submenu">
    <h2><?php
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    ?></h2>
    <ul>
    <?php wp_list_pages("title_li=&child_of=$parent" ); ?>
    </ul>
    </div>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic