The is just a quick WordPress code snippet for those WordPress programmers or code dabblers out there.
Recently we needed a page in WordPress to display the top parent page title rather than the current page’s title as the heading on the page. Here’s the code we used to accomplish that:
<?
$currPost = $post;
while ($currPost->post_parent) {
$currPost = $currPost->post_parent;
}
$title = get_the_title($currPost);
?>
<h2>[ <?php echo $title; ?> ]</h2>
Tags: WordPress, programming