Here is the my code, which is not working.
global $post;
echo get_the_title( wp_get_post_parent_id( $post->post->ID ) );
but this is not working.
thank you in advance.
While there's probably a plugin for this, we have created a quick code snippet that you can use to get parent page title in WordPress. $parent_title = get_the_title( $post ->post_parent);
Bookmark this question. Show activity on this post. $page_object = get_queried_object(); $page_id = get_queried_object_id(); // "Dirty" pre 3.1 global $wp_query; $page_object = $wp_query->get_queried_object(); $page_id = $wp_query->get_queried_object_id();
What Is a Parent Page? A WordPress parent page is a top-level page in the site's hierarchy. The group of sub-pages nestled under it are called child pages.
php if(is_shop()){ $page_id = woocommerce_get_page_id('shop'); }else{ $page_id = $post->ID; } ?> Hope this will help you.
For parent page id
$post->post_parent;
For current page title
$post->post_title;
For parent page id
<?php
echo wp_get_post_parent_id(get_the_ID());
?>
In Gutenberg:
wp.data.select('core/editor').getEditedPostAttribute('parent')
Hope will be helpful to someone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With