i just did this for a site i am working on. first i registered 2 menus in functions.php:
add_action('init','kia_menus');
function kia_menus(){
register_nav_menus( array('primary-menu' => __( 'Primary Menu for Logged In Users', 'kia_theme' ),
'primary-loggedout' => __( 'Primary Menu for Logged Out Visitors', 'kia_theme')
));
}
and then where i want the 1 menu to appear based on the user’s status (probably in header.php but depends on your theme):
if( !is_user_logged_in() ){
wp_nav_menu( array( 'theme_location' => 'primary-loggedout' ) );
} else {
wp_nav_menu( array( 'theme_location' => 'primary-menu' ) );
}
Related Posts:
- Walker class: Problems with understanding how walk() method can be called without error
- How to create different menu’s for not logged in visitors and for logged in members?
- Remove all nav menu classes ( but keep useful ones… )
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- create a select input with menus created on a custom options page
- Add data-id attribute to child page links
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Featured image in menu wordpres
- How to get the count for each taxonomy term
- Adding first / last CSS classes to menus
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Show the most popular post per week
- Add a class to links in the visual editor (how to get old dialog back)
- How to remove hardcoded characters from playlists?
- Creating custom Woocommerce attribute taxonomies from a plugin
- how to put the logo in the center of other items in the navigation bar
- renaming an admin menu item with decimal array index number
- Load post content into iframe
- wp_customize_image_control default value
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Limit the Excerpt field in WP-Admin in words
- Can we have a php “page” without a WordPress “page”?
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- wp_delete_auto_drafts() deletes links in menus
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
- Logout and redirect using the WP Menu
- Creating new menu item
- Programmatically create menu with custom link
- Custom Loop through category menu to include sub categories
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Random Default Avatar Function
- Change the site tagline (or similar) based on current page
- Customizer: Output default value in Customizer CSS
- Converting HTML Template to WordPress Theme
- Add data attribute to each li in menu
- How to pick the default selected value in wordpress dropdown?
- Remove metabox from WordPress menu editor page?
- Customize position of social icons in upme plugin [closed]
- Secondary navigation menu on one page
- Remove class in nav_menu_link_attibutes filter
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Media Upload , file name changed automatically
- Replace shortcode in substring
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Adding PHP in the menu
- What exactly do this function declared into functions.php file of a WP theme?
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- customize wordpress database error page
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- Where is the PHP code generating an element?
- Basic wpdb update question
- Ajax search shows all results when user empties input?
- List post by title length
- Need help with pagination
- Notice: Trying to get property of non-object
- Adding Additional Variables on Menus Page
- pagination broken – clicking next displays “page not found”
- Class for Selected Menu using wp_nav_menu
- Editor capabilities – admin_init
- Hard-coding a shortcode as the last menu item in primary navigation?
- WP insert post Redirect after function has executed
- Create condition for Author bio Social Links
- Nav Walker that shows only children and siblings of top level parent menu item
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- How can I add diffrent editable text fields?
- Woocommerce template file outputting tags
- Trying to update Woocommerce meta values
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- How to let mobile navigation menu close when link is clicked?
- Need help transforming echo to return for use with shortcode
- Noob question: want to remove the “site identity” logo for specific part of website only
- Create Schema in WordPress with PHP
- PHP warning with code for nav menu walker [duplicate]
- Add element after navigation element title don’t works like I expect
- String replace for Login/Logout concatenation problem in menu
- Redirect after login depending on the URL
- How to create a sub-page of sub-page?
- Real time notification on user profile after new comment
- How to add text before posts
- Add two or multiple functions in WordPress Post or Page
- Only display notification on single post
- Adding button to wordpress menu
- WordPress error on my website
- wp_nav_menu prints children with parent name
- WP Admin Bar – Get current theme name as custom menu title
- Best way to define a database with product codes and back-end support?
- wp_customize_image_control default value
- Widget header unique classes
- why is this content-template not showing any of my blog-entries?
- How to add button to top of theme customizer?
- Submenu opened problem
- How can I add more code to this?
- Save Option on Database
- Edit the Publish Widget Options
- New to WordPress & Freelancing [closed]