You are missing a link. The posts are not assigned to the menus directly. There is a post type nav_menu_item
in nav_menu
taxonomy which links posts (or other kinds of destinations) to their place in menu.
This snippet should get you started on retrieval:
$menu_items = get_posts( [
'post_type' => 'nav_menu_item',
'meta_query' => [
[
'key' => '_menu_item_object_id',
'value' => get_the_ID(),
]
],
] );
foreach ( $menu_items as $menu_item ) {
var_dump( get_the_terms( $menu_item->ID, 'nav_menu' ) );
}
Related Posts:
- Adding Post Counts to Menu (Nav) Programmatically?
- Disable most recent & view all (TABS) on nav-menu.php
- How to create a submenu that will navigate through different posts in the same page
- One menu for frontpage (one pager), and a different menu for posts
- Show posts count for Categories and Tags in wp_nav_menu
- Page and Posts loading as index page? Not loading the content
- Passing a hardcoded page/post ID into `get_post`
- MySQL Query to Retrieve Category from wp_posts
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How to add post count to wp_nav_menu?
- Getting the Next and Previous Posts Titles in the Sidebar?
- the_post_navigation seems to ignore same category filter
- Adding a Nav menu to post admin
- Is it possible to show a different WP menu when using password protected pages?
- Navigation link to specific user page
- get_terms parent for current product only
- Adding Multiple Values to a Post Meta Key
- What Defines What Category A Post Picks (if in multiple)
- Post Navigation
- WordPress menu that shows all posts in a certain category like w3schools
- Mark menu item as current-menu-item for category
- Restrict post navigation to current sub menu
- Sidebar links for different pages
- Create dropdown list post
- get_next_post() and get_previous_post() return wrong posts
- Avoid duplicate post from same Taxonomy
- Blog Posts in Custom Menu
- Set terms in a custom post
- Get posts of ONE taxonomy term of custom post type
- Is it possible to create a form post wordpress custom navigation link?
- remove older posts link [closed]
- Setting posts_per_page for taxonomy term template
- How to Next and Prevous Navigation Buttons on the end of the page with custom image Using Wp Post Navigation Plugin
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- How to list recent posts in a wp nav menu?
- How to display posts via custom taxonomy terms using checkboxes?
- sql select for post_title and a term name
- Highlight static blog page link in header
- Using wp_list_pages() after calling query_posts()
- How to add category post count in main navigation menu [closed]
- disable Tab post on nav-menus page (Admin)
- Loop parent terms {display posts} AND loop child terms {display posts}
- Restrict the_post-navigation to same category?
- How to Use index.php file for “Blog” Page And this is Not a Home Page
- How can I list posts by author?
- Is there a way to add the list of recent posts into the admin sub menu on hover?
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- Parent category / child category posts
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- Only allow posts with a specific term to only be viewed by other authors with the same term in their post
- WordPress pagination and Post Navigation not working on home page
- WordPress post filter menu
- Accessing Post ID Within Loop
- Programmatically add posts from specific category to menu
- Add Text Domain To Post Navigation
- How to show next/prev link, when it’s not active?
- How to output all taxonomy links from a custom post type in a menu?
- Making a new post visible on a specific page
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- Menu does not foward to the linked posts
- Blog posts pagination not working
- Menu Items disappearing/being empty on save or post edit
- Get post slug and match with menu item slug to change css
- I want to add the 10 most recent posts under a parent category on the main menu
- Go back to the exact post page number
- How do I scope out why I have two “posts” menus in an admin?
- Change URL of previous posts and next posts link in WordPress
- Parent menu item does not display posts when I add the sub-items
- How to make certain posts not appear on the main page, but instead only a newly created category(in the menu section)
- Creating a link to the first post in a category
- Next / Previous post in a single category
- Automatic Table of contents with categories and posts
- Loop through taxonomies and loop through their terms (Newbie question)
- Using WP page password protection as defacto login
- I lost the link to my posts in my menu bar
- How can we print out total number of posts filtered by post type and category?
- How to add navigation arrows to manually slide through posts?
- How to add content to the menu
- Can the_post_navigation() be outside of the loop?
- display content in multiple columns
- Output wp_link_pages as raw url
- Keep highlight on menu item with post pages
- Call posts of particular category in a page
- Add custom class to existing menu items from custom meta
- Hiding menu on mobile only when viewing posts?
- Displaying Results From Custom Taxonomy Query
- Load Pages Menu in single.php
- Display Post by menu order
- How to get all the terms of a post
- Count > 1 Navigation Slider
- How do I paginate posts page with $wpdb?
- How do i put a dropdown list of ALL my post in the sidebar menu?
- ‘get_previous_post’ in same category returning (!empty) when no previous post in category exists
- Adding a post to a page
- How can I get the first post THIS SAME CATEGORY?
- How to detect if an ACF custom-field is really in use?
- Dynamic Menu Item
- Show a page counter for pagination
- How can I merge a several related posts into one post?
- How to remove category and other tags from posts page