How to get a parent page name

Is there an easy way to retrieve the name of the parent page of a WordPress page?

Add this code to your plugin or functions file:

[php]
<?php
/**
* Get parent page name
*/
add_filter( ‘gform_field_value_parentname’, ‘wpster_get_parent_name’ );
function wpster_get_parent_name( $value ) {
return apply_filters( ‘the_title’, get_the_title( wp_get_post_parent_id( get_the_ID() ) ) );
}
?>
[/php]

Submit a Comment

Your email address will not be published. Required fields are marked *