Reputation: 368
I have a page ID number stored in a variable. However I'm trying to access that specific page ID numbers parent page title.
Could someone lead me in the right direction.
Upvotes: 1
Views: 1264
Reputation: 346
Please try to use the following code:
get_the_title(wp_get_post_parent_id($your_post_ID));
Upvotes: 4
Reputation: 1506
For the current page:
<?php
echo empty( $post->post_parent ) ? get_the_title( $post->ID ) : get_the_title( $post->post_parent );
?>
If that ID is some others page ID i would say run a query on the DB itself to get that title.
Upvotes: 0