On my site, I'm trying to customize the sidebar to be specific to a parent and its children by listing related parent/children pages as well as listing relevant category posts.
So, within a new UL, I have the following code:
<ul class="events">
<?php if (is_page()) {
//we're looking at a static page again. Which pages?
if (is_page(array(5, 1752, 1768, 1749, 1764, 1775, 1754, 89, 1758)) && $post->post_parent)
// Children's pages and subpages
query_posts('cat=20&posts_per_page=10');
elseif (is_page(array(6, 630, 1878, 1882, 779, 1880, 1884)) && $post->post_parent)
// Adult pages and subpages
query_posts('cat=62&posts_per_page=10');
else query_posts('cat=12&posts_per_page=10');
}
while(have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
If I am on page id=5 and any of its children, and likewise id=6 or any of its children, I want a list of only category 20 or 62 title links respectfully to appear on each page.
The end resulting lists would be different from 5 to 6 and then default list on the rest of the WP pages.