Found this way:
if ( 0 == $post->post_parent ) {
the_title();
} else {
$parents = get_post_ancestors( $post->ID );
echo apply_filters( "the_title", get_the_title( end ( $parents ) ) );
}
Anyone got a better way please answer.
Related Posts:
- page title, parent tilte and grand parent title
- How WordPress manages nested dropdown?
- Determine page content based on page parent
- What is a subpage in WordPress?
- How do I quickly hide a hierarchy of pages from search engines and external users?
- Use an archive as the parent of a page?
- wp_list_pages get the hole hierarchy for current page
- How to publish pages under a subdomain url?
- Advanced Multi Tier Navigation across columns
- How to get current page ID outside the loop?
- How to give paged links custom title?
- featured image as background image on pages
- How to add a specific widget to only 1 page?
- Find empty pages or pages which have less than x characters
- Get wp_get_attachment_url outside of loop
- How to add or remove metabox each page separately?
- Prevent WordPress from adding linebreaks to javascript embedded in a page
- How to display list of child pages of parent page in wordpress?
- Automatically change page password
- Too many pages causes WordPress admin to be unusable
- more tag in the $post->content when get_pages were used
- Different “Text Widgets” in Sidebar on Many Different Pages?
- Guidelines for adding static pages
- How to display thumbnail and excerpt of a page on homepage?
- How to echo excerpts with wp_list_pages?
- Remove pages from backend list *and* update counter accordingly
- How do i fix? WordPress database error: You have an error in your SQL syntax;
- WordPress Admin – Add Edit link to specific page under Pages Menu
- Show child pages and sibling pages on the child page
- How do I use featured images on index.php?
- Making a wordpress page the index on the site?
- Removing the TinyMCE editor for a given page template
- How to call wp_list_comments() outside of the comments template?
- Using Pages to handle calls for custom post types
- Displaying Subpages while on Parent page?
- Guest authors, sort of like Wikipedia, but more theme-able
- WordPress redirects me to posts page after editing one page
- Getting to a specific page on website using specific code instead of navigation bar
- Pages views limit [closed]
- Redirect to page list when page published
- Having wordpress page accesss issue under sub-directory
- How to make my category archive behave like a page
- Add external css to Contact Page
- Role can edit just one page [closed]
- Suddenly forbidden 403 error on some pages
- how to edit source code of specific page in wordpress?
- How to select a specific page
- Where can i make an html change to a specific page [closed]
- Cannot enter “::before” for li tag when editing a WordPress page
- How to get page_id for url rewrite or how to use page slug for calling a page?
- JQuery Plugins in WordPress
- Dynamic href link to Contact Page
- Restrict the list of parent pages to only those which are created by current user
- how can i remove page title on desktop view
- Use content from one page in another template
- Is there a way to schedule changes to a page?
- How do I edit text displayed on my browser tab?
- Is it possible to change slugs’ default behaviour?
- List child pages within page template
- Option for pages order in backend
- Return subpages of an author if the parent page was published by an other author
- Page menu not showing in admin, new Page button missing in toolbar too
- Allow a user to edit their own page and profile only
- WordPress Page doesn’t load the template selected
- Custom folder for wordpress page templates
- Separate URL for a specific page
- Pages that don’t look like blog posts?
- Can I use Pages like a Wiki
- list child-pages as normal pages?
- Next and Previous Page links based on ‘Order’ attribute
- Create multiple pages with tables from json file
- register_rest_field only for specific page
- Update Pages ONLY from Stage to Live (not products)
- Attaching a file to a page without adding to media library?
- Every change made by “Author” role is going to “pending review”
- Groping Pages Per Department Option
- Requiring a Visitor to Enter a Password Each Time They visit a Page
- WordPress default theme cannot get full page on entry content div
- Create multiple custom HTML pages
- Add homepage to the list of pages in the Footer Widget
- How to remove the duplicate title tags and duplicate meta descriptions?
- Two different layouts for the same post
- My page title turns into a h2 tag – What to do?
- problem with loading pages
- How to turn post into pages and via versa?
- Content not displaying on page
- Blank white space where header was [closed]
- How do I get my page “About” to show up on my WordPress site?
- Featured Image not displaying in a page
- Display child pages on homepage template
- Set order acs and no paging for archive page
- Pulling posts tagged with similar title name
- search page different results
- simple category search form returns full text – but I need excerpts
- Naming custom page templates
- How can I use Page editor for two separate templates?
- Sort the data in WordPress using get-page-by-title
- Adding a filter to wp_edit_posts_query() to prevent hierarchical display of pages
- Order pages by date
- In WP, Google map error initMap is not a function [closed]