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
- Remove Container Element From wp_nav_menu() Markup
- 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
- Check if has any sidebar active on current page
- Remove Page Title from Static Frontpage
- How to activate “Description” metabox for menu item programmatically?
- Dynamically add sub-categories to any category in the menu
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Two different menus for two different locations?
- automatically adding submenu items
- Unregister Nav Menu with fallback?
- How to programmatically set a menu to be the Primary Menu?
- Editing or filtering the output of the Genesis navigation
- Pages should have priority when using add_rewrite_rule
- Enqueuing Script in functions.php vs on the page
- 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
- Is there a way to add a class to non current menu item?
- Logout hyperlink within a sub-menu
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- 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?
- is_account_page() change to page slug
- 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
- Don’t delete a page if it holds users
- Make parent page only link to first subpage
- How to add nav menu items to a specific position within a menu
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- 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
- Custom Nav Walker sub-menu
- 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
- Get page id or status by private pages?
- Categories as main menu items and subcategories as nested lists
- Removing specific menu items?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- disable Tab post on nav-menus page (Admin)
- How do I hook into the container of wp_nav_menu?
- Enqueue script on every page except one
- New custom menu created. how to apply it?
- Dropline menus — seperators between children only?
- Filter nav menu items HTML tags and wrap inner text with span
- retrieves menu and converts it to a readable array
- 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]
- Default Nav Highlight
- why is this function firing on all child menu items as well?
- 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?
- Multiple navigation menu in same location
- How do I register a new settings page? [closed]
- 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
- current_page_item is missing inside wp_nav_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