Archived topic
secondary navigation copies items of primary navigation
5 replies · Started by Kaleem on December 16, 2017
hello sir, my secondary navigation shows the same items of primary navigation.
i want to insert different items to the secondary navigation, but both share the same items.
hope you can help me solve it. thank you.
Hi there,
You need to create two separate menus for each navigation: https://docs.generatepress.com/article/using-the-wordpress-menu-builder/#setting-a-theme-location
The problem was a php code added to my child.
I added the code just to show different menu to logged-in/logged-out users. i really need that function, but im not good at php at all.
Sir, can you please fiddle the code to fit with both the primary and the secondary menu? I want both the primary and the secondary be shown to a logged-in user while a different menu shown to a logged-out user. here is the code:
function my_wp_nav_menu_args( $args = '' ) {
if( is_user_logged_in() ) {
$args['menu'] = 'logged-in';
} else {
$args['menu'] = 'logged-out';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Thank you in advance.
Perhaps it would be better to use a plugin like this?: https://en-ca.wordpress.org/plugins/nav-menu-roles/
Nice one. Thank you for the help.
You're welcome :)