Original topic: Echo the subtitle of a PARENT page within WordPress?
I\'ve discovered a separate need for the code Mark produced in relation to the orig
if you are trying to achieve the same thing (refer here) but this time for the title,
you can do this:
post_parent!=0) {
// for child pages
$permatitle = get_post_meta(end( get_ancestors( get_the_ID(), 'page' )), '_base_page_subtitle', true);
} elseif($post->ID==0||count(get_pages('child_of='.$post->ID))==0) {
//for HP or pages with no child
$permatitle = get_post_meta(get_option( 'page_on_front' ), '_base_page_subtitle', true);
} else {
// for top level pages/parents
$permatitle = get_post_meta($post->ID, '_base_page_subtitle', true);
}
or better yet, combine the two:
post_parent!=0) {
// Handling of Child Pages
$permalink = get_permalink( end( get_ancestors( get_the_ID(), 'page' )));
$permatitle = get_post_meta(end( get_ancestors( get_the_ID(), 'page' )), '_base_page_subtitle', true);
} elseif($post->ID==0||count(get_pages('child_of='.$post->ID))==0) {
// Homepage or Pages with no Parent
$permatitle = get_post_meta(get_option( 'page_on_front' ), '_base_page_subtitle', true);
$permalink = home_url();
} else {
// Handling of Top Level/Parent Pages
$permatitle = get_post_meta($post->ID, '_base_page_subtitle', true);
$permalink = get_permalink( end( get_ancestors( get_the_ID(), 'page' )));
}
then you can do this after: