I'm try to build a menu with wp_list_pages()
that must work like this:
Main Page
-Subpage1
-Subpage2
I check if the Page has_subpage and i can see the 2 subpages when i'm in the Parent but when i'm visit one of the subpages i don't see anything. So, what i can do to check if page has subpages to get the same list of pages in the subpage(s)?
How i use it: in the functions i check if the Page has_subpage,
function has_subpage (){
global $post;
$pages = get_pages("sort_column=menu_order&depth=1&child_of={$post->ID}");
if ($pages) return TRUE;
}
and in my template i call the menu (list of subpages),
<?php if (is_page() && has_subpage()) { ?>
<?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0$sort_column=menu_order");
$title_heading = get_the_title($post->post_parent);
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$title_heading = get_the_title($post->ID);
}
if ($children) { ?>
<?php echo $children; ?>
<?php } ?>
<?php } ?>
the problem is inside has_subpage() function, cause if i don't use it i get the pages correct, maybe i'm missing something here?
thanks a lot!