Get Page Parent

Posted on Thursday, December 4th, 2008 at 12:39 pm in

<?php // Get the parent of a page
$this_post = get_post($post->ID,ARRAY_A);
if($this_post['post_type'] == 'page') {
	$this_parent_id = $this_post['post_parent'];
	if($this_parent_id > 0) {
		$this_parent = get_page($this_parent_id,ARRAY_A);
		$this_parent_title = $this_parent['post_title'];
		$this_parent_uri = get_page_uri($this_parent_id);
		$this_parent_link = '<a href="'.$this_parent_uri.'">'.$this_parent_title.'</a>';
		echo $this_parent_link;
	}
}?>
You might also be interested in

WordPress Installation and Set Up

Top