Created
July 12, 2015 07:45
-
-
Save ideag/63ec21da36c2684dd3af to your computer and use it in GitHub Desktop.
Vary menu based on some logic (user role, current page, etc.)
This file contains hidden or 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
<?php | |
// ... | |
register_nav_menu( 'primary', __( 'Primary default location', 'yourtheme' ) ); | |
register_nav_menu( 'primary-subscriber', __( 'Primary subscriber location', 'yourtheme' ) ); | |
register_nav_menu( 'primary-account', __( 'Primary account location', 'yourtheme' ) ); | |
// ... | |
?> |
This file contains hidden or 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
<?php | |
// ... | |
$args = array( | |
'theme_location' => 'primary', | |
); | |
if ( current_user_can( 'read' ) && !current_user_can( 'edit_user' ) ) { | |
$args['theme_location'] = 'primary-subscriber'; | |
$args['walker'] = new Your_Walker_Class; | |
} | |
if ( is_page('account') ) { | |
$args['theme_location'] = 'primary-account'; | |
} | |
wp_nav_menu( $args ); | |
// ... | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment