OK I’m doing a a menu (sidebar menu) that will display this all child pages of parent page (currently open)
Parent
|-Child 1
|-Child 2
|Child 3
but in same time when someone is in bolded page (child) will see the same thing
Parent
|-Child 1
_ _|-Child 1
_ _|-Child 2
_ _|- Child 3
|-Child 2
|-Child 3
currently I use next code which do first job well but not the second one with child of child I tried several things but nothing worked
<?php if ( is_page() ) {
if($post->post_parent)
$children = wp_list_pages('title_li=&child_of=".$post->post_parent."&echo=0&sort_column=post_date&sort_order=DESC'); else
$children = wp_list_pages('title_li=&child_of=".$post->ID."&echo=0&sort_column=post_date&sort_order=DESC');
if ($children) { ?> .......
Thanks in advance
Edit
As Simon answered it worked but not for all cases and I edited so now final code is:
<?php if ( is_page() ) {
$stats = count($post->ancestors);
if($post->post_parent){
if($stats == 2){
$children = wp_list_pages('title_li=&child_of=".get_post( $post->post_parent )->post_parent."&echo=0&sort_column=post_date&sort_order=DESC&depth=1');
}else{
$children = wp_list_pages('title_li=&child_of=".$post->post_parent."&echo=0&sort_column=post_date&sort_order=DESC&depth=1');
}}
else{
$children = wp_list_pages('title_li=&child_of=".$post->ID."&echo=0&sort_column=post_date&sort_order=DESC&depth=1');
}
if ($children) { ?> ....
That’s in case if somebody else need this stuff, Cheers and thanks for fast help