How to get displayed child pages on parent page and also on child page of that parent in sidebar?Trying to paste code from wp codex page and from several other sites, but with no success.I always get instead of list of child pages, list of parent pages!? what is the problem?Just to mention, maybe is important, all parent pages have its own page-template.
example code:
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
I also try this code which seems to me doing god job, but again I got list of parent pages
wp_reset_query();
after the custom loop? you can check if the sidebar gets the page ID by adding this before your code:<?php echo $post; ?>
global $post;
before your code, considering you are using it in a textwidget with the 'exec php' plugin.