This has only been a problem since I updated to Wordpress 3.1
I have a page that displays a list of custom post types. The page is the child of a parent page. There is a sidebar that lists sibling pages. The code for the two is conflicting somehow, and I can't get the list of pages to show up.
This is the code to display the list of custom post type (in my case 'sponsor'):
<?php
$args = array( 'numberposts' => 30, 'post_type' => 'sponsor' );
$sponsors = get_posts( $args );
foreach ($sponsors as $post) : setup_postdata($post);
?>
<div class="content">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
<?php endforeach; ?>
This is the code in my sidebar to list the sibling pages:
<?php
if (!$post->post_parent) {
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
} else {
$p = end(get_post_ancestors($post->page));
$children = wp_list_pages('title_li=&child_of='.$p.'&echo=0');
}
?>
<?php
if ($children) {
$parent_title = end(get_post_ancestors($post));
?>
<ul>
<?php echo $children; ?>
<?php } ?>
</ul>
Nothing is showing up in the sidebar. I tried deleting the code for the posts, and the list of pages showed up correctly. But something about the "get_posts" is not letting the "list_pages" work.
Anyone know what alternate code I can use?
wp_reset_query
, it's suppose to clear up variables used by template tags inside post loops.