I'm designing a highly customized WordPress theme with a self-written static sidebar. One of my sidebar blocks shows a single post, in order to display a poll with an image. You can see an example at:
The poll displayed in the sidebar is a separate loop, written with the following code:
$polls_cat = "45"; $poll_query = new WP_Query('cat='.$polls_cat.'&showposts=1&orderby=date&order=DESC'); while ($poll_query->have_posts()) : $poll_query->the_post(); update_post_caches($posts);?> <h2 id="pollboxtitle"><?php the_title(); ?></h2> <div id="featuredpicture"> <!-- featured picture wrapper --> <img height="200px" width="300px" src="<?php echo get_post_meta($post->ID, 'thumbnail',true); ?>" alt="Post Image" class="postimg" /> <div class="caption"><?php echo get_post_meta($post->ID, 'thumbnailcaption',true); ?></div> </div> <!-- /featuredpicture --> <?php the_content(''); ?> <?php endwhile; ?>
When viewing the first page of a paginated post (split into two pages using the
<!--nextpage--> tag, the poll displays perfectly. HOWEVER, when viewing the second page of the paginated post, as at the following URL:
the_content() appends the content of the second page of the post at the end of the poll, causing the post to display twice, once in the main body of the page, and once in the sidebar, underneath the poll.
I've isolated this problem to paginated posts; it doesn't seem to be happening anywhere else on the site.
I'm something of a newbie when it comes to WordPress, and a lot of what I've done has been done without necessarily knowing whether or not it's the best way to do it or not. I'm thinking that I've done something wrong concerning the_loop(), but doing things like wp_reset_query(); doesn't seem to have any effect.
Can anyone give me some advice about how I should be doing this? I've searched around and, possibly due to the strangeness of the problem, can't find any information on it.
I'm using several plugins to customize my template, including Popularity Contest and a modified version of Lester Chan's PostViews plugin.