I've created sidebar tabs that display the most recent, popular and random posts. In other words I'm creating several loops in my sidebar. This seems to cause some problems, though. Do I have to reset something or just use a complete different code overall?
The code for the sidebar tabs looks like this:
<div id="tabvanilla" class="widget">
<ul class="tabnav">
<li><a href="#popular"><img src="http://zoomingjapan.com/wp-content/themes/alltuts/images/41.gif" border="0" alt="41" /> Popular</a></li>
<li><a href="#recent">Recent</a></li>
<li><a href="#random">Random</a></li>
</ul>
<div id="popular" class="tabdiv">
<ul id="popular-comments">
<?php
$pc = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>
<?php while ($pc->have_posts()) : $pc->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?></a>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
<p>Posted on <strong><?php the_time('F jS, Y') ?></strong><br />
<span class="sidebar_content"><?php echo excerpt(8); ?></span></p>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
</div><!--/popular-->
<div id="recent" class="tabdiv">
<ul id="recent_posts">
<?php
$rp = new WP_Query('orderby=date&posts_per_page=5'); ?>
<?php while ($rp->have_posts()) : $rp->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?></a>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
<p>Posted on <strong><?php the_time('F jS, Y') ?></strong><br />
<span class="sidebar_content"><?php echo excerpt(8); ?></span></p>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
</div><!--/recent-->
<div id="random" class="tabdiv">
<ul id="random_posts">
<?php
$ranp = new WP_Query('orderby=rand&posts_per_page=5'); ?>
<?php while ($ranp->have_posts()) : $ranp->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(50,50)); ?></a>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php comments_popup_link('(0)', '(1)', '(%)'); ?>
<p>Posted on <strong><?php the_time('F jS, Y') ?></strong><br />
<span class="sidebar_content"><?php echo excerpt(8); ?></span></p>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
</div><!--random-->
</div><!--/widget-->
The current issue is that the first tab "Popular" displays 5 posts as it should, but the other 2 tabs display 6 posts, although I've clearly coded it so that only 5 should be displayed!!!!
My website is here for reference (if you use IE - and I hope you don't - please don't be shocked that apart from the tab above none other is working - there are a lot of issues in IE suddenly (since yesterday) possibly caused by CSS, maybe some HTML error - am working on it currently).
Thanks a lot in advance!