Have you tried the following function:
<?php get_post_ancestors( $post-ID ) ?>
The last post in the returned array should be the highest level ancestor.
This is from the Codex.
Related Posts:
- Get ID of the page where shortcode is included
- How to get current page ID outside the loop?
- How to get page title with the page ID?
- What is an alternative to get_page_by_title()?
- Get wp_get_attachment_url outside of loop
- Get page id by title?
- How to embed page content in a blog post
- Audio or playlist shortcode condition according to the amount of files on attachment page
- Debugging shortcode problems
- How to exclude shortcode from specific page IDs if it’s set to global
- Cannot get grandparent object
- Shortcode produces blank page
- conditional tags- how to use with shortcodes
- Show own shortcode data on each page
- How to retrieve attachments from child pages of a specific Page?
- How to get ID of the page included with get_page()?
- Attachment pages stealing page slugs
- How to get page_id for url rewrite or how to use page slug for calling a page?
- Is it possible to check for shortcodes on a page?
- How To Render Shortcode In AJAX Response?
- Is it possible to restrict access to specific pages in the admin area based on the page slug?
- List child pages within page template
- Is there a way to show attachment IDs on the attachment info screen?
- Make Audio Element Persistent Across Pages
- How to get an array of pages ID by some page’s slug and all its children pages in get_posts() function?
- Shortcode runs when editing page
- How to insert current user ID in a shortcode?
- How to show the view more on my display of pages shortcode
- Pre-populating new Page creation with shortcodes
- How to output different content of page on different places in my template
- custom page or standalone page?
- Using Post ID and Page ID in same function
- get id custom tables on current page
- How to read a page’s “Shortcodes” from the Template File?
- How to set post slug when using wp_insert_post();?
- Check if is on child-page of a particular page
- What methods to use to create small, editable pieces of text for static pages?
- Hide page visual editor if certain template is selected?
- explode array within shortcode
- Notify admin when page is edited?
- How do I modify this page template to show subpage excerpts (not post excerpts)?
- Dynamically Load Styles and Scripts from Theme Functions.php
- How should I best incorporate WordPress in my static website?
- What are the options for running custom css and javascript files on a page?
- How to build a post and comment editing form in a page?
- Wrong Sub-Page Order
- Can’t change parent page
- can i create 2 blog ‘feeds’ within one blog
- Call the content of a page in AJAX in WordPress
- I made a custom page but WordPress seems to strip any HTML I put in this page
- Change names of pages in wordpress
- WASM page in WordPress website
- Include a specific page in your template
- Is it possible to have a landing page based on the visitors location?
- Remove number in URL
- Shortcode for a link and thumbnail
- Displaying page content in category archive (archive.php)
- Is it possible to skip certain specified pages when using < prev and next > links?
- Custom Page Order instead of Alphabetical
- How to redirect a page to another?
- How to create a page that lists all the experts(Users with same access permission as author)?
- How to update the title of audio file through its attachment metadata
- How to control who can view certain pages in BuddyPress? [closed]
- access control for assets in a website powered by wordpress
- How to remove only pages from Admin Bar?
- ‘x’ Converted to html code in example: 5×10
- Published pages missing
- Getting ACF Field in Page – From the Footer
- Different css file not working for the page template I created
- How to change the order of the Front Page so it doesn’t appear first
- 404.php only works if I’m logged in. Everybody else redirects to wp-login.php – why?
- Using index.php as page template
- Use full size images in a specific gallery
- What’s the section of code (or loop) which retrieves the Page title and description?
- Auto embeds don’t work for attachment descriptions
- Template field missing in page attributes
- How to hide a page in wordpress made for menu
- How to change default home link title?
- Recovering a page from the drafts
- Pulling images from the media folder category to display inside a page
- My Password Protected Pages Aren’t Working
- Page view displays not properly after update wordpress
- Is it possible to query a category with specified posts?
- Display grandchild page content on parent page
- Converting HTML to WordPress theme: integrating pages function and using its text editor, conditional enqueuing
- Display custom_post_type with current taxonmy of a page
- How to add conent (text) to Add New pages form of admin in WordPress
- How to copy specific page content and create child page?
- WordPress slow pages/post, hangs and white text
- Prevent page from displaying
- Previewing Draft shows white page, publishing works fine?
- Changing title bar in browser window of theme “Encounters Lite”
- Custom Filter using meta_value in wordpress admin list not working
- Loading custom jQuery and HTML in a WordPress page
- Dynamic content in pages
- Javascript will not run properly
- link a custom page into menu
- Website fully loads then immediately crashes in Internet Explorer [closed]
- How to display a page?
- How can a user login on a wordpress page?