Site logo

Archived topic

sidebar sub-navigation

16 replies · Started by Les on March 6, 2017

Viewing posts 1–15 of 17

I did several forum searches but couldn't find a solution.

I'm looking to do sub-navigation in the left sidebar. I would like only the current website section (not to be confused with GP Sections) and it's children to appear in the sub menu.

Is this possible without having to create a separate, stand-alone menu for each section? I would like it if it just used the global menu so that my client just has to maintain one menu.

Here's the site I'm working with:
http://www.vwnaus.com/themeone/sub-navigation/

Thank you in advance!

Hmm then you can try using CSS and target each page and menu item. So something like this:

.page-id-## .inside-right-sidebar .menu-item-## {
    display: none;
}

It will be a bit of work to go through each page but you should be able to keep it to one menu.

Thank you for the feedback Leo. I was hoping there was something that would be a little more automated. Like to where it would programmatically know what section of the site was the current one; and hide the others.

Kind of like how WP is able to set the current page class on the li in the menu so you can have the current page/section be a different color. e.g. li.current-menu-parent

Thanks again!

You got me thinking and I'm close to getting it to work with CSS...I think...

All told Leo, I love the idea of a simple CSS solution. Looking forward to what you find out!

Any updates on the CSS solution? Thank you!

If Tom doesn't think it's possible with CSS then it's definitely not possible. sorry to get your hopes up! Looks like a plugin would have to do.

Thank you Tom!

I'd like to avoid another plug-in, so I'm trying the WP Tutorial you linked.

Added this to my child-theme functions.php:

//sub-page display from -> http://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-child-pages-for-a-parent-page-in-wordpress/
function wpb_list_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
else
$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
if ( $childpages ) {
$string = '

    ' . $childpages . '

';
}
return $string;
}
add_shortcode('wpb_childpages', 'wpb_list_child_pages');

I attempted to create a new page template by duplicating the GP page.php file and adding it to my child theme directory... but since this is related to the sidebar, I think that I'll need to hunt for a different tutorial.

I also tried to add the shortcode [wpb_childpages] to my left sidebar widget, but nothing displays on the front-end.

http://www.vwnaus.com/themeone/sub-navigation/

Thank you again for the assist!

Looks like you got it working&gt? I see the submenu in the sidebar now.

Using [wpb_childpages] in your text widget would be the way to go for sure :)

This archived topic is closed to new replies.