use get_page twice like this handy little function
function get_grandpapa($page_id){
$current_page = get_page( $page_id );
if ($current_page->post_parent > 0){
//has at least a parent
$parent_page = get_page($current_page->post_parent);
if ($parent_page->post_parent > 0){
return $parent_page->post_parent;
}else{
return false;
}
}
return false;
}
This function returns the grandparent page ID or false if there is no grandparent.
Related Posts:
- Show more than 20 items in pages or posts edit dashboard
- How to display last 3 posts (recent posts) in a static page?
- How to load javascript on custom page template?
- Change page template programmatically ?
- Conditional tag to check if ‘page.php’ is being used?
- Get top level page parent title
- Editing Complex Pages in Visual Mode
- Link section within page with slash (/) and not hash (#) without reloading the page
- Creating a template using a specific slug name, for a page with a parent page
- Is there a default template file for child pages / subpages?
- Multiple areas of dynamic content in a page
- How to create virtual pages with information from user meta profile fields?
- Increment Page Order As Pages Are Created
- Private pages that work when you are not logged into WP admin
- Is there a way to remove or hide individual pages on the Edit Pages screen?
- Add custom admin menu item for pages using a certain template
- Where does the 404 redirection happen?
- Display latest comments on page with pagination
- How to add pages to feed?
- Add custom text at bottom of every page?
- Creating custom page
- How to create a metabox that will list all my pages in a dropdown selector?
- Relative instead of absolute links in pages?
- Produce a plain page with only a message
- load common thank you template with different content for different pages
- Password Protected Page Title
- Load specific page template based on URI
- Page displays content from different query?
- Site url is not showing the home page
- Can’t locate a hidden private page
- Page redirects to archive
- Making audio playlist by getting page’s parent’s ID
- Restricting Pages based on Hierarchy and User Role
- Pages Column Sorting WordPress Version 3.0.3
- Adding Page URL to the Pages Admin Table
- More Fields Required For Password protect page
- page-name.php doesn’t execute on custom template
- Add categories and posts to page hierarchy
- How to retrieve attachments from child pages of a specific Page?
- Admin taking a very long time to load
- how to display sidebar on pages in wordpress
- WordPress Site Page Exists but Error 404
- How to capture GET argument on static page
- page.php is not called, falls back to index.php
- I would like my page editor to be sorted by date created, or updated, instead of in Alpha order, is this possible?
- Show FormCraft form on page open [closed]
- Why last blog post excerpt is shown instead of meta description? [closed]
- Prevent non-admin to add/create new pages
- How do you implement a page template automatically being applied to a page?
- Make “default” wordpress pages & features unaccessible
- How to create cutom link for page
- Set a variable to using in redirected page
- creating single page with 2 columns while theme is 3 column
- Show parent & child pages with featured image and hide the current page
- Outputting content from page
- Use an archive as the parent of a page?
- Publish page by invoking submit via jQuery
- One author not showing in Author drop down list while editing page
- WordPress Page Protect forwards to Admin Login
- How can I edit pages from my local environment?
- Modifying .page-content background image
- How to show page title with capitalization only as I typed in?
- Make Audio Element Persistent Across Pages
- My site does not load but downloads a file (wordpress)
- what does the symbol “?” mean and how can i edit that page?
- How to remove a page in its entirety
- Display latest comments (global) with replies on a page
- Set different heights per screen size with inline styles CSS into the ‘Text’ section of a Page
- Some pages can’t be updated – post_content field not updating
- How to add custom php file to right sidebar?
- Why my home page doesnt work?
- Mailchimp RSS feed work with single wordpress page?
- How to publish pages under a subdomain url?
- how to setup subdomains for pages?
- How to approach need for virtual page on my WP site?
- How can I change the background color of a contact box? [closed]
- Creating content using wp-admin pages
- change page status with code
- Attach link to pages accoding to tags
- Search Page: activate html code if the tag is on the page
- How to end the Page Load Event and load after that?
- How can I add a new page in the pages tab that belongs to specific theme?
- New page has incorrect URL
- Pages redirecting to homepage
- How to migrate .HTML pages to WordPress
- Separate Editing from Publishing for pages
- Call a function on every wordpress pages only
- Programatically create multiple pages by passing in array of info
- How do I make just one of my pages a Blog Page?
- Standard way of creating profile pages with custom content for each user?
- How to show parent pages on a specific page if user is logged in?
- Create custom archive page for individual authors which is separate from the author.php page
- Showing certain page without redirection
- How to add or remove metabox each page separately?
- Retrieve page content and pass to PHP?
- Get moderation notifications on one post only
- Advanced Multi Tier Navigation across columns
- Display random page
- Display list of posts with x tag within a page?
- Fresh WordPress installation not able to simply show page content