Okay, figured it out! I’ve amended my theme function as follows:
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'top_navigation') {
$items .= wp_nav_menu( array('menu' => 'menu-logged-in', 'container' => '', 'echo' => false, 'items_wrap' => '%3$s') );
}
elseif (!is_user_logged_in() && $args->theme_location == 'top_navigation') {
$items .= wp_nav_menu( array('menu' => 'menu-logged-out', 'container' => '', 'echo' => false, 'items_wrap' => '%3$s') );
}
return $items;
}
So now, just gives me the <li>
items I need and rendered in the correct position. Hope this helps someone.
Related Posts:
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- How to add a data attribute to a WordPress menu item
- How to display custom field in woocommerce orders in admin panel?
- How to create a custom order status in woocommerce!
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Get menu object from theme_location
- How to show product SKU on product page
- How do I hook into the container of wp_nav_menu?
- New custom menu created. how to apply it?
- Dropline menus — seperators between children only?
- Filter nav menu items HTML tags and wrap inner text with span
- retrieves menu and converts it to a readable array
- Create custom function for hero image
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- Secondary Menu and Logged In Users
- Change menu based on page template via functions.php
- replace text in Sort Box
- Show some menu sub items as dropdown under a menu item
- add_filter to specific WooCommerce Category
- Woocommerce checkout field
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- How to add custom li item to wordpress menu
- Way to redirect all Product Sub Category to its Main category Page?
- Create a Woocommerce product widget with category filter
- Delay a function, any function!
- Default Nav Highlight
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- why is this function firing on all child menu items as well?
- Different methods of adding menu support to custom theme
- Adding a section in line at the end of the main navigation menu in php
- How add body_class from wp_termmeta
- Multiple navigation menu in same location
- Adding product to WooCommerce cart [closed]
- Change WooCommerce add_to_cart Button Text?
- wp_nav_menu work in functions.php but not in the theme
- How to register a menu based on a ACF condition
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- current_page_item is missing inside wp_nav_menu
- search form leads to 404
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- Custom Menu in Admin doesn’t change menu in browser
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Conditional custom menu?
- wp_nav_menu displaying all pages
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Warning at top of website & top menu gone
- How to hide content on mobile in the functions.php file – woocommerce
- Woocommerce Default sorting product by product type
- How to hide WooCommerce product title and short description to non logged in users?
- How to display an image before title text in menu items
- How to add custom metakey to shop_order page’s searching function?
- localize_script but data changes dependent on product ID
- Changing the HTML of notices in WooCommerce [closed]
- Change class woocommerce on function.php
- Bizarre Child Menu Issue on WP Site
- Show ‘Add to Cart’ on Out of Stock products
- Header menu aligned right on all pages except for single-post page [closed]
- Hide ‘add to cart’ when certain value in dropdown is selected
- removing description tabs – single product page – breaks footer
- Link product attribute value to a URL – woocommerce
- Remove text after a dot and a colon in Woocommerce product title
- When are the user meta fields created in the database? Admin vs Woo API REST
- price of product can’t return when get data of product in functions.php
- Woocommerce product price change
- Help with with my function for wordpress
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- is_product_category(‘Services’) not working
- How to automatically add counted number to navigation menu items?
- Problems adding a new field to product in cart
- Parent category as WOOCommerce Categories widget title
- Woocommerce Display Discount On cart
- Problem with my footer after changing WooCommerce Products Sorting [closed]
- Combine multiple menus using the filter wp_nav_menu_items
- Menu and category highlighting for a single post
- Variable function names
- WordPress Toggle Menu has stopped working
- Override plugin function to show invoices even if not logged in
- Woocommerce – Switching Price for Category
- how can I change the read more link destinations and direct all to the same page?
- Woocommerce custom calculation function
- button to toggle css styling / div visibility?
- add product thumbnail to checkout page only and include variation name
- Echo a String Based On Geolocation? [Woocommerce || ACF]
- Execute jQuery with custom event listener after successfully add an item to the cart
- Move product attributes after summary on single product page
- Which method is more correct for removing WooCommerce Extensions menu item?
- Show number of sold products but be first for less than 2
- How to add widget in main menu
- function syntax is off,
- Language Switch Function
- Adding custom field in menu options [duplicate]
- Modify sub_menu function to show pages below a specifically set page
- wp_nav_walker that interacts with widgets to setup mega menu