I’m trying to code this slider for our WordPress site to show in each box, the first, second and third most recent posts from the category (in this instance it’s sports). No matter what I do with the count variable I can’t get the other posts to show up, just the first one. Here is the loop I’m using and the code, the page is smeharbinger.net/category/sports
<div class="tabbed">
<!-- tab 1 -->
<div class="t1">
<ul>
<?php
$count = 1;
$tabbedSportsQuery = new WP_Query('cat='.get_query_var('cat').'&showposts=1');
while ($tabbedSportsQuery->have_posts()) : $tabbedSportsQuery->the_post();
echo '<div class="t'.$count.'">';
echo the_post_thumbnail(array(665,500), array ('class' => 'alignnone'));
$count++;
endwhile;
?>
</ul>
</div>
<!-- tab 2 -->
<div class="t2">
<ul>
<?php
$count = 2;
$tabbedSportsQuery = new WP_Query('cat='.get_query_var('cat').'&showposts=1');
while ($tabbedSportsQuery->have_posts()) : $tabbedSportsQuery->the_post();
echo '<div class="t'.$count.'">';
echo the_post_thumbnail(array(665,500), array ('class' => 'alignnone'));
$count = 2;
endwhile;
?>
</ul>
</div>
<!-- tab 3 -->
<div class="t3">
<ul>
<?php
$count = 3;
$tabbedSportsQuery = new WP_Query('cat='.get_query_var('cat').'&showposts=1');
while ($tabbedSportsQuery->have_posts()) : $tabbedSportsQuery->the_post();
echo '<div class="t'.$count.'">';
echo the_post_thumbnail(array(665,500), array ('class' => 'alignnone'));
$count++;
endwhile;
?>
</ul>
</div>
<!-- The tabs -->
<ul class="tabs">
<li class="t1"><a class="t1 tab" ><h10><?php echo get_the_title($ID); ?></h10></a> </li>
<li class="t2"><a class="t2 tab" ><h10><?php echo get_the_title($ID); ?></h10></a> </li>
<li class="t3"><a class="t3 tab" ><h10><?php echo get_the_title($ID); ?></h10></a> </li>
</ul>
</div><!-- tabbed -->
Try this. Note:
while
loop will then loop through these for you.The
$count++
increases the count from 1 to 2 to 3.Hope below code will help you.. Loop thru the post and then print div for tab and then try to get remaining tabs into a variable and at end of while loop print that variable.