“PRIMARY” and “secondary” menu bar really don’t mean anything when used out of context and without explanation. However, (guessing a lot) if your menus are constructed consistently you should be able to find the ‘name’ of the second menu and add a condition like (overly formatted for readability):
if (
is_user_logged_in()
&& (
$args->theme_location == 'menu_top'
|| $args->theme_location == 'other_menu_name'
)
) {
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
Same with the elseif
.
Look for a call to wp_nav_menu
in your theme files to find the ‘name’ of the second menu.
Related Posts:
- Masking logout URL
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Logout Redirect and also WP-login.php Redirect
- wp_enqueue_script was called incorrectly
- Remove a menu item created by a plugin
- Logout redirect to current page – function
- Logout/login redirect CSS issue
- How can I tell if I’m on a login page? [duplicate]
- Is it possible to use a forgot password url filter?
- redirect wp-login.php to another page
- Login using the password from protected pages
- automatically adding submenu items
- How do I redirect upon login a specific user based on role?
- Logging in redirects to correct page but shows logged out content until forced refresh
- Remove default user registration, login and subscriber profiles
- is_user_logged_in not working to redirect only logged out users
- Logout hyperlink within a sub-menu
- Members only site – still need the lost password page accessible
- How to change login labels
- Login/logout in header
- How can I get my Script to work on the Login page?
- Login Redirect if Logged in from Specific Page
- Custom Nav Walker sub-menu
- Unable to login using username
- When a user logs in, how can they view the website instead of the admin menu?
- WordPress PHP Conflicting User Sessions
- Get User Login Data (date, time… )
- Registration Hooks don’t appear to be working
- If user is logged-in display/hide something
- retrieves menu and converts it to a readable array
- Secondary Menu and Logged In Users
- Prevent WordPress Automatic Logout
- error at login page in wordpress
- why is this function firing on all child menu items as well?
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- loginout function customization
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- Show errormessages on wrong username/password on custom loginform?
- Conditional custom menu?
- WordPress login set cookie that survive browser exit (wp_signon function)
- This code is supposed to only allow user to be authenticated if accountVerified is equal to 1, but it still allows user to be authenticated otherwise
- Prevent wp_signon redirect on failed login for ajax login
- How to redirect Subscribers on login to specific page, when logging in from a Page
- How to replace ACTION url from original wordpress login form?
- Unable to login after registration
- Allow logged in user to view a Page, else send to login screen and then redirect back to Page
- Redirect after login to current URL
- Login functions
- WordPress permanently logging users out
- Modify sub_menu function to show pages below a specifically set page
- How to request login for user but not for bots
- is_user_logged_in() isn’t working
- How do I get my nav menu to show sub pages?
- update_user_option not working as expected
- “Headers already sent” while trying to add a CSS file to my login page?
- Logout redirect via page template without confirmation?
- Disable visual editor on one specific page
- How to display random users with avatars
- Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?
- In a WordPress plugin, how do you output HTML code inside the DOM header? [closed]
- Different ‘WP_CONTENT_URL’ for different subsites in Multisite setup?
- Preferred Use of home_url()?
- wordpress custom login successful redirect hook
- Make “sidebar template” the default template for new pages
- Refactor create_function
- Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]
- Attach parent category template to all subcategories
- How to insert a text in all pages and posts before or after specific places?
- How to remove howdy dropdown menu content
- Change Admin Bar “Visit Site” URL
- Stop turning small dashes into longer ones
- Execute function after a post has been published
- Last updated date function
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- How to set default archive image without overriding first attached image? [closed]
- Passing a variable via wp_head and then calling it on the page
- Load Woocommerce and WordPress Functions Outside
- How to know which ajax file or function is called for action
- watermarking gallery items
- Change menu based on page template via functions.php
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- Why is it so hard to add a class to the tag in the sidebar widget?
- Parent theme styles overriding child theme CSS [closed]
- Adding theme option values as custom body class
- How to add a new image size and apply it to posts only?
- add_menu_page() with variable function
- Why is this function crashing my wordpress installation? [closed]
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- How to Override Page Template if URL matches query?
- Woocommerce Display Discount On cart
- How to create admin ajax function for my contact form
- how to display featured image for single post for a specific category
- save_post hook – headers already sent?
- How to use WP_rewrite?
- Wp get archive only text not link
- Display post_meta-by_key on product catalogue
- What are the parameters are used in add_action and filters?
- Does functions.php apply to every page?
- Different ads on every website on multisite environment
- How to get variable from other function inside class function using add_action for Ajax call