“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?
- Simple way to make most of my site private
- wp_login_form display no styled form
- Redirecting after login except for a specific page
- wp enqueue style on about us page
- CF7 select value get to function and reciept value from function
- wp_get_current_user return ID = 0 when used outside of wordpress, such as webhook / fulfillment dialogflow
- Fatal error: Call to undefined function load_theme_textdomain() in /var/www/vhosts/61/151172/webspace/httpdocs/wp-includes/functions.php on line 5
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- Hide author info in single posts by certain users
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Creating a custom functions page wordpress
- Remove text after a dot and a colon in Woocommerce product title
- sort title descending with title with number
- Delete oldest wordpress post (SQL query)
- Add #primary at the end of navlink permalinks on single posts
- search and replace using regex
- post value to function with Ajax and jQuery
- When are the user meta fields created in the database? Admin vs Woo API REST
- Selecting specific query for offset
- Enqueue script if not page template
- External api call and make global variable for any page visitor enters , page-home, page, single etc
- Is_Page doesnt detect my page
- How do you insert code into the sidebar?
- How Do I Unhook This Parent Theme Function?
- price of product can’t return when get data of product in functions.php
- Including Font Awesome in a Custom Theme
- remove_filter function to unhook twentysixteen parent theme function
- WP AJAX Request Not Working
- Test CDN link from function.php or wp_enqueue_script/style?
- Problem with is_user_logged_in() function in some pages
- Woocommerce product price change
- Remove the ‘category’ url for one category type
- Can we have conditional CSS styling?
- CSS style and app.js not loading
- Change function without filter hook
- Security when outputing wp_oembed_get code
- Help with with my function for wordpress
- Widget is displayed in two places
- Allow user only create specific tags
- is_email gives me error
- Trying to change widgets h-tags
- only update titles of single posts
- Post content overflows on my mobile phone
- Stylesheet does not load despite functions.php