You could of course use some preg_replace()
tricks to solve this, but here’s a little (untested) idea using the the_title
filter instead:
add_filter( 'the_title', 'wpse_title' );
$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0");
where our filter callback is:
function wpse_title( $title )
{
remove_filter( current_filter(), __FUNCTION__ );
return __( 'Overview' );
}
Remark 1:
I think you should consider replacing the wp_list_pages()
method of generating the single parent link and instead use get_permalink( $parent_id )
or get_page_link( $parent_id )
from the parent page ID. Then you can easily from control the link name.
<li>
<a href="https://wordpress.stackexchange.com/questions/156742/<?php echo get_permalink( $parent_id ); ?>">Overview</a>
</li>
You already use this for one of the levels, so why not for others as well?
Remark 2:
You could also use get_post_ancestors()
to help you get the current tree level position.
For example:
$ancestors_ids = get_post_ancestors( get_the_ID() );
$level = count( $ancestors_ids ) ;
Then you can get the parent ID, of the current page, with:
$parent_id = ( $level > 0 ) ? array_shift( $ancestors_ids ) : 0;
Here’s an example of how the case $level = 2
could look like:
<ul class="submenu">
<li>
<a href="https://wordpress.stackexchange.com/questions/156742/<?php echo get_permalink( $parent_id ); ?>">Overview</a>
</li>
<?php echo wp_list_pages("title_li=&child_of=".$parent_id."&echo=0&depth=1"); ?>
</ul>
Maybe your $level = 1
could then be:
<ul class="submenu">
<li>
<a href="https://wordpress.stackexchange.com/questions/156742/<?php echo get_permalink( $parent_id ); ?>">Overview</a>
</li>
<?php echo wp_list_pages("title_li=&child_of=".get_the_ID()."&echo=0&depth=1"); ?>
</ul>
etc ..