Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Output Parent Page WordPress

  • SOLVED

I use the following line in a code which outputs subpages and a parent to specific child page levels. This code outputs the name of the parent page. I would like to replace this with the word "Overview."

The line that grabs the parent:
$children = wp_list_pages("title_li=yo&include=".$post->post_parent."&echo=0"); // list the parent page

How do I achieve this in wp_list_pages with as little code as possible? (Please provide the full code.) Thanks!

<?php
if ( is_page() ) {
$parent = get_post($post->post_parent);
$parent_title = get_the_title($parent);
$grandparent = $parent->post_parent;
$grandparent_title = get_the_title($grandparent);
$current_page_parent = ( $post->post_parent ? $post->post_parent : $post->ID );

// is the homepage the granparent? = third level page
if ($grandparent == is_page('0')) {
$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); // list the parent page
$children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); // append the list of children pages to the same $children variable
if ($children) {
?>
<ul class="submenu">
<?php echo $children; /*print list of pages*/ ?>
</ul>
<?php
}

// is the homepage the parent? = second level page
} elseif ($post->post_parent ==is_page('0')) {
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
if ($children) {
?>
<ul><li class="current_page_item"><a href="<?php echo get_permalink( $parentid ) ?>">Overview</a></li><?php echo $children; ?></ul>
<?php
} else {// your else stuff
} } }
?>

Answers (1)

2014-08-10

Arnav Joy answers:

can you describe more about what you want ?
I am not clear with your explanation above


Lucas Wynne comments:

You can see my menu here: http://themeforward.com/demo2/practice-areas/criminal-law/

It contains "Overview" as a link to the parent. Now, click on a child page like "Clerk's Hearings" or "Appeals" and the "Overview" link becomes "Criminal Law" (the parent page). I would like this to say "Overview" as well.


Arnav Joy comments:

i checked these 3 pages:-

http://themeforward.com/demo2/practice-areas/criminal-law/
http://themeforward.com/demo2/practice-areas/criminal-law/clerks-hearings/
http://themeforward.com/demo2/practice-areas/criminal-law/criminal-appeals-massachusetts/

all those are ok , having title "Overview" , let me know where is the problem.