The page ID (or object ID, since a menu item can link to any object) is stored in the postmeta
table, with the key _menu_item_object_id
. So you can get the page ID with the following code:
get_post_meta( $item->ID, '_menu_item_object_id', true );
Related Posts:
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Make menu structure match page heirarchy on page parent change
- How to add a class name to the ancestor of a post?
- How to add a data attribute to a WordPress menu item
- Why isn’t is_page working when I put it in the functions.php file?
- Add container to nav_menu sub menu
- Get menu object from theme_location
- Disable visual editor on one specific page
- Using wp_get_nav_menu_items() to list children of children pages
- How to target specific wp_nav_menu in function?
- How can I programmatically create “child” pages on theme activation?
- Breadcrumbs showing Parent and Child Pages
- Custom menus displaying all pages instead of set pages
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- How to display error messages using WP_Error class?
- Slugs as breadcrumbs for Pages
- Remove Page Title from Static Frontpage
- Dynamically add sub-categories to any category in the menu
- Two different menus for two different locations?
- automatically adding submenu items
- Editing or filtering the output of the Genesis navigation
- Pages should have priority when using add_rewrite_rule
- Programmatically set page template based on page ID
- Delete pages and Create default pages for all new network sites
- how to change link of some wordpress pages
- Change the slug of a particular page every x hours
- wp_insert_posts keeps adding multiple pages
- Logout hyperlink within a sub-menu
- How to include local menu based on page id?
- CSS for menu item added via functions.php
- How To Remove Duplicate Menu Locations
- Batch update menu_order attribute alphabetically
- 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]
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- 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
- Hard-coding custom menu elements for menu manager
- Display post shortcode content in the sidebar?
- Why is my page feed returning empty content?
- Function only on a specific page
- How to fetch the name of the active menu?
- Functions For Calling Specific Elements
- Replace a menu with widget or a custom template file programmatically
- Removing specific menu items?
- How do I hook into the container of wp_nav_menu?
- Enqueue script on every page except one
- Dropline menus — seperators between children only?
- Filter nav menu items HTML tags and wrap inner text with span
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- Secondary Menu and Logged In Users
- Change menu based on page template via functions.php
- Show some menu sub items as dropdown under a menu item
- How to add custom li item to wordpress menu
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Different methods of adding menu support to custom theme
- Adding a section in line at the end of the main navigation menu in php
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- wp_nav_menu work in functions.php but not in the theme
- How to register a menu based on a ACF condition
- Only echo Page Content (not page title & page content together)
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- search form leads to 404
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- get content from page through AJAX
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- Custom Menu in Admin doesn’t change menu in browser
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Conditional custom menu?
- wp_nav_menu displaying all pages
- How to assign php file(template) to several pages with same prefix page name/slug
- Warning at top of website & top menu gone
- How to display an image before title text in menu items
- Bizarre Child Menu Issue on WP Site
- How to automatically add counted number to navigation menu items?
- Combine multiple menus using the filter wp_nav_menu_items
- Menu and category highlighting for a single post
- Remove the delete link from pages without a plugin
- Change is_front_page() to is_page() to display ‘hero’ on entire site?
- Language Switch Function
- Insert menu into theme location depending on user logged in/out status
- Define an extra field for all pages (with no plugin?)
- Adding custom field in menu options [duplicate]
- Custom field not updating via functions upon publishing
- Modify sub_menu function to show pages below a specifically set page
- Adding a filter with custom function to the menu / navigation
- Using array page name together with page id to deregister script
- Function Reference for custom link in Admin Menu Management Page
- How do I get my nav menu to show sub pages?
- Adding Pages to Menus – No Page Hierarchy in Backend [duplicate]
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?
- My website is generating weired url parameters of paginated pages
- Call wordpress function through functions.php when pressing menu
- How to add more than one menu for logged in members?