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
- Apply the_title() filter in post & page title, but not in menu title
- 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 are terms connected with posts in database?
- 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
- Importing data from spreadsheet into wordpress DB, along with custom taxonomies and their terms
- 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
- deleting terms programmatically
- Adding Multiple Values to a Post Meta Key
- What Defines What Category A Post Picks (if in multiple)
- Edit menu item title from edit page/post
- 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
- Get latest posts from WordPress site without header, menu and sidebar
- 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]
- Is it possible to change post id for an already added menu item in WordPress?
- 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
- More then one menu items are assigned with “current-menu-item” class
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- Show only one page link in content pagination
- 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?
- WordPress Menu options in the Admin: Posts for the dropdowns
- 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
- Navigate through the posts using keyboard arrows
- Parent category / child category posts
- wp_set_object_terms NOT working on CPT, but wp_set_post_terms does
- 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
- Count the number of a post types associated with another post type
- WordPress pagination and Post Navigation not working on home page
- WordPress post filter menu
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Accessing Post ID Within Loop
- Programmatically add posts from specific category to menu
- Add Text Domain To Post Navigation
- wp_list_categories() Exclude All Categories Except One
- 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
- Possible?! A contextually titled back link
- Post navigation using date
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- Featured Images most often doesnt appear
- 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 to add class to specific navbar item when post parent category is in specific category
- 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
- get_next_post() not working with future post status
- How to make certain posts not appear on the main page, but instead only a newly created category(in the menu section)
- Excluding category from post navigation in WordPress?
- 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?