Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Secondary Menu and Logged In Users

wp_nav_menu_args is a filter inside wp_nav_menu, which is used to display navigation menus on your site. The $args parameter passed to the filter is an array containing the wp_nav_menu arguments. By default they are the following,

$defaults = array(
  'menu'            => '',
  'container'       => 'div',
  'container_class' => '',
  'container_id'    => '',
  'menu_class'      => 'menu',
  'menu_id'         => '',
  'echo'            => true,
  'fallback_cb'     => 'wp_page_menu',
  'before'          => '',
  'after'           => '',
  'link_before'     => '',
  'link_after'      => '',
  'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
  'item_spacing'    => 'preserve',
  'depth'           => 0,
  'walker'          => '',
  'theme_location'  => '',
);

You can find these also in the wp_nav_menu code reference and in its source code. (These are merged with the theme supplied arguments by wp_parse_args before being passed to the wp_nav_menu_args filter.)

This means you can use the parameter to check for example which location the filter is currently handling.

add_filter('wp_nav_menu_args', 'my_wp_nav_menu_args_filter');
function my_wp_nav_menu_args_filter($args) {
  if ( isset($args['theme_location']) && 'my-theme-location' === $args['theme_location'] ) {
    // do something
  }
  return $args;
}

(For Storefront the location slug is secondary, which you can find in the source code.)

Related Posts:

  1. Remove Container Element From wp_nav_menu() Markup
  2. Breadcrumbs showing Parent and Child Pages
  3. Return only top-level navigation items from a menu using wp_get_nav_menu_items
  4. Menu fallback “menu_class” rendering a “div” instead of a “ul”
  5. How do I create page navigation linking to each H2 within the page? [closed]
  6. Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
  7. Categories as main menu items and subcategories as nested lists
  8. retrieves menu and converts it to a readable array
  9. Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
  10. Default Nav Highlight
  11. Multiple navigation menu in same location
  12. loginout function customization
  13. Show errormessages on wrong username/password on custom loginform?
  14. How would I make a function to dynamically determine if user is logged to change navigation menu text?
  15. Bizarre Child Menu Issue on WP Site
  16. How to automatically add counted number to navigation menu items?
  17. How to add widget in main menu
  18. wp_enqueue_script was called incorrectly
  19. How to add a data attribute to a WordPress menu item
  20. Adding fields to the “Add New User” screen in the dashboard
  21. How to check if a user exists by a given id
  22. Is there a is_user_logged_in() for multisite?
  23. Get the ID of the page a menu item links to?
  24. Add container to nav_menu sub menu
  25. Mega Menu Walker
  26. Get menu object from theme_location
  27. Use author author display name in permalink structure for pages and posts
  28. Displaying Logged-In User Name in WordPress Menu
  29. Get a list of all available fields in the User Profile
  30. Logout redirect to current page – function
  31. How to paginate the get_users function?
  32. Using wp_get_nav_menu_items() to list children of children pages
  33. How to target specific wp_nav_menu in function?
  34. How to display random users with avatars
  35. Masking logout URL
  36. How to manually activate user in dashboard only by admin
  37. Add new user : make the fields First Name and Last name required
  38. How can I tell if I’m on a login page? [duplicate]
  39. Is it possible to use a forgot password url filter?
  40. Custom menus displaying all pages instead of set pages
  41. wp_delete_user with username
  42. How to manually add an item to a submenu in a menu generated by wp_nav_menu?
  43. redirect wp-login.php to another page
  44. How to activate “Description” metabox for menu item programmatically?
  45. Dynamically add sub-categories to any category in the menu
  46. Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
  47. Order get_users() by last login date. Is it possible?
  48. Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
  49. Two different menus for two different locations?
  50. Login using the password from protected pages
  51. automatically adding submenu items
  52. How can I tell when a user is logged in?
  53. How do I redirect upon login a specific user based on role?
  54. Logging in redirects to correct page but shows logged out content until forced refresh
  55. how to get and display logged in user’s recently read posts
  56. Displaying a random user with a shortcode
  57. Unregister Nav Menu with fallback?
  58. How to update BuddyPress xprofile fields programmatically? [closed]
  59. How to detect first visit of a user?
  60. How to programmatically set a menu to be the Primary Menu?
  61. Editing or filtering the output of the Genesis navigation
  62. Can I pass two roles to the function get_users?
  63. Logout and redirect using the WP Menu
  64. How can I add an image field to BuddyPress Extended Profile Fields? [closed]
  65. Remove default user registration, login and subscriber profiles
  66. Create dropdown of users in admin dashboard
  67. password protected post policy
  68. Make menu structure match page heirarchy on page parent change
  69. is_user_logged_in not working to redirect only logged out users
  70. Remove the deleted users avatar from list
  71. Is there a way to add a class to non current menu item?
  72. Logout hyperlink within a sub-menu
  73. Members only site – still need the lost password page accessible
  74. CSS for menu item added via functions.php
  75. How To Remove Duplicate Menu Locations
  76. Get Current User info using wp_localize_script, in functions.php
  77. How to add custom fields to my custom registration form
  78. Where do I add html code to the menu div?
  79. Breadcrumbs – Exclude Child Categories
  80. Replace menu links with # and add name to its li
  81. Function issue with Walker_Nav_Menu [duplicate]
  82. How to change login labels
  83. create shortcode to list users with specific meta key value
  84. Why does the ‘wp_nav_menu’ function work only until a menu is created?
  85. Hide Hamburger Menu On Specific Page (Front Page/Home Page)
  86. Don’t delete a page if it holds users
  87. Make parent page only link to first subpage
  88. How to add nav menu items to a specific position within a menu
  89. wp_nav_menu, walker class, categories as classes of li
  90. Hard-coding custom menu elements for menu manager
  91. How to make custom column Admin>Users sortable?
  92. How can I get my Script to work on the Login page?
  93. Execute a ultimate member action when user role is updated
  94. Filter out other users comments. Visualize only own comments and editor role users’ comments
  95. Force to use STRONG users password and implement rule to prevent REUSE [closed]
  96. Login Redirect if Logged in from Specific Page
  97. Custom Nav Walker sub-menu
  98. Unable to login using username
  99. How to fetch the name of the active menu?
  100. Change label for registration Fields
Categories functions Tags functions, login, menus, navigation, users
Page not found if mod_cache_disk is active
Prevent A Specific Custom Post Type Showing In WP Search Results Page

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress