How To Show Parent Page Title instead of Subpage

This is a cool simple tutorial, if you are using WordPress as CMS. This tutorial helps you show Parent Page Title regardless of what subpage you are on. So on whatever subpage you go, you still see Parent Page title. It comes handy when you use WordPress as CMS, for example in news site.

How To Show Parent Page Title instead of Subpage

Its simple, all you have to do is pase the below code where you want to show the Parent Page title.

1
2
3
4
5
6
7
8
<?php
if($post->post_parent) {
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
} else {
    wp_title('');
}
?>

Thanks to WPRecipes

Add a Comment

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