Hook int 'wp_nav_menu_objects'
. You get a list (an array) of all found menu items as an array. Each item is an object, and each one has a property named ID
. That’s the ID of the original object if it was a post object.
In your filter callback just iterate over these items, collect the IDs and use them later in your custom query.
- See How to var_dump nav menu items from anywhere? for a plugin to collect these items for later usage.
- In Dynamically link to the latest post I showed a case where the ID is empty. Prepare for that in your code. 🙂
Related Posts:
- wp_get_nav_menu_items() not working with slug
- Error “Trying to get property of non-object” with Custom Walker for wp_nav_menu
- Add Class to Specific Link in Custom Menu
- How do I add a search box to the nav menu?
- How to get IDs for objects in menu branch?
- How to move parent li to end of child ul
- wp_nav_menu() loses ‘current-menu-*’ classes on single product page within category
- How is custom menu hierarchy output handled?
- How to fix strange 500 Error after Editing Menu?
- Remove ‘Menus’ from Twenty Sixteen theme Customizer
- Creating new dynamic menu including BP links [closed]
- Custom nav walker with different output depending on depth
- List parent item with all child item on child pages
- Override custom menu widget
- Custom Nav Walker sub-menu HTML construct
- Placing widget to menu
- container_class doesn’t seem to be working
- Get menu item slug
- Walker_Nav_Menu: Items not nested correctly
- Loop through Navbar, Output Icons
- Custom Walker anchor tag not inheriting attributes
- Check what “type” a menu item is
- How to display dynamic content in start_lvl function
- Partial refresh of menu in customizer not working?
- Add custom -element to wp_nav_menu
- Disable automatig SVG tag from menu
- next_post_link() on custom menu structure
- Different fields available for different sites when when customising Menu’s
- Custom walker with hashes instead of links (one-page layout)
- Find out if a page has no parent
- wp_nav_menu() showing list in a different Position?
- Can’t include Language switch in Nav Menu
- Using website header, menu and footer on WordPress blog
- Add within the output of
- Add CSS to head depending on nav menu walker
- burger on mobile
- Hierarchical menu nesting problem with jQuery targetting
- How to make next and previous button based on a menu
- How to combine multiple categories in one Menu item?
- 2 Different Nav Menus Have Same Name in WP-Admin
- WordPress Menu Walker: add #hashes to child page links (only)
- add_filter on menu items to add a menu item
- WordPress Walker – Group two items?
- Unlimited WordPress Menu
- How to show dynamic side bar on menu item [closed]
- Creating a Mega Menu
- Remove a menu sub-item
- How to remove menu labels in word press?
- modify menu item links dynamically
- Where is my menu editor
- Adding numbers inside a span tag in nav menu [closed]
- I’m using wp_nav_menu to display my menu, but I want one more link in there that is a hardcoded link. How can I do this?
- WordPress Menu adds an unwanted slash before anchor
- Hoverable menu to appear in different sections of page
- How to automatically redirect to first item of second navigation level in a multi-level menu?
- Secondary menu in WP 4.5
- Change link in menu on condition
- How to undo the last changes to a custom menu?
- Creating other page than page.php
- Add menu headings to WordPress sub menus
- add_menu_page does not render the expected result
- Custom menu styling
- Getting the WordPress custom menu titles and outputting them in a theme
- Second Level Menu
- Different Menus based on Category Page
- Additional navigation bar in header
- Dynamically populate the menu when a new category is created
- Is there any difference between widgets (used in order to manage menus) and register_nav_menus() in terms of performance?
- current-menu-item not apllying with wp_nav_menu() on ajax
- Menu items not clickable
- Hide a menu (navigation bar) on all posts
- How do you show horizontally the submenu in WordPress using the nav walker?
- Adding menu title to custum URL
- Parent Menu Item Requires Two Clicks for Mobile Device
- Add “onclick” option to header menu item
- Full submenu not displaying in wordpress
- Mobile menu not working – jQuery error?
- Product categories are mixed when creating menu
- Responsive Dropdown Menu
- Header lists posts instead of showing primary nav menu
- Add a menu item to the logged in users author page?
- Count Level 1 Childs for Custom Nav Walker WordPress
- Iterate through each menu item into a shortcode
- “Static” Child Menu with Accordian
- Display same menu for parent and all its children
- Image menu on responsive WordPress
- Set a different home link in nav menu
- Remove link from Page name in navigation bar
- Prevent Menu Shortcode From Formatting
- Auto Filled Custom Menus for Custom Post Types?
- Setting up menus before making a template live
- Adding Pages to Menus – No Page Hierarchy in Backend [duplicate]
- Is it possible to add a superscript trademark symbol to a menu?
- Creating a Horizontal menu
- I want my homepage navbar to have different styling to the rest of my site, how can I do this?
- How does WP knows which template to use for a page
- Problems with draft website pages
- Sub menu for a (single) page
- Add acf custom fields so sub item in menus
- change breakpoint widths for divi theme tablet view