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 display custom field in woocommerce orders in admin panel?
- How to create a custom order status in woocommerce!
- Get menu object from theme_location
- How to show product SKU on product page
- Woocommerce add to simple product attribute programmatically [closed]
- Using wp_get_nav_menu_items() to list children of children pages
- In WooCommerce I need to modify the thankyou.php page [closed]
- Breadcrumbs showing Parent and Child Pages
- Custom menus displaying all pages instead of set pages
- Dynamically add sub-categories to any category in the menu
- How to Acheive the custom woocommerce category template
- Two different menus for two different locations?
- Remove product description from product archive page
- Hide some items from Screen options in dashboard for products
- Unregister Nav Menu with fallback?
- Editing or filtering the output of the Genesis navigation
- Can you use admin pages functionality on the frontend of your site
- Creating loop within functions.php
- Override woocommerce wc-class function
- Display WooCommerce subscriptions for user [closed]
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- Is there a way to add a class to non current menu item?
- Woocommerce checkout field maxlength, make input number field only (postcode)
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- change in form-checkout.php by using code in functions.php
- CSS for menu item added via functions.php
- How To Remove Duplicate Menu Locations
- Set quantity of woocommerce product on page visit [closed]
- Where do I add html code to the menu div?
- Replace menu links with # and add name to its li
- How do I create page navigation linking to each H2 within the page? [closed]
- Function issue with Walker_Nav_Menu [duplicate]
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- Make parent page only link to first subpage
- wp_nav_menu, walker class, categories as classes of li
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- How to display custom option field in woocommerce orders in admin panel?
- How to auto refresh when user change postcode
- Remove the product category module block from the Woocommerce product page
- Custom Nav Walker sub-menu
- Replace a menu with widget or a custom template file programmatically
- Functions when woocommerce isn’t installed
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Dropline menus — seperators between children only?
- retrieves menu and converts it to a readable array
- Functions php shortcode for displaying main menu with no child items
- replace text in Sort Box
- Woocommerce checkout field
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- Way to redirect all Product Sub Category to its Main category Page?
- 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
- How add body_class from wp_termmeta
- Adding product to WooCommerce cart [closed]
- 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
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- How to hide content on mobile in the functions.php file – woocommerce
- How to hide WooCommerce product title and short description to non logged in users?
- localize_script but data changes dependent on product ID
- Bizarre Child Menu Issue on WP Site
- 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
- Woocommerce product price change
- Help with with my function for wordpress
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- Problems adding a new field to product in cart
- Combine multiple menus using the filter wp_nav_menu_items
- Variable function names
- 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
- Move product attributes after summary on single product page
- Which method is more correct for removing WooCommerce Extensions menu item?
- wp_nav_walker that interacts with widgets to setup mega menu
- How do I get my nav menu to show sub pages?
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Get term count on a category page
- add variable to actions/functions across different files (woocommerce)
- reusing code in function and running it with loop
- Call wordpress function through functions.php when pressing menu
- How to add more than one menu for logged in members?
- sort by date in users
- Is it possible to set the first image from a gallery as the product image, rather than the featured image?