Created
July 27, 2022 12:13
-
-
Save texe/b09e34ed3f1dc02576b6383e39c14192 to your computer and use it in GitHub Desktop.
WordPress - show different menus for logged in users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Different menus to logged in users | |
function md_nav_menu_args( $args = '' ) { | |
if( is_user_logged_in() ) { | |
// Menu for logged users | |
$args['menu'] = 22; | |
} else { | |
// Menu for non-logged users | |
$args['menu'] = 23; | |
} | |
return $args; | |
} | |
add_filter( 'wp_nav_menu_args', 'md_nav_menu_args' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment