How to add different class in last child of loop in wordpress.
<ul class="categories_list cat_main">
<?php
$args=array('posts_per_page' => 6,'post_type' => 'post','orderby' => 'meta_value', 'meta_key' => 'views','order'=> 'DESC', 'post_status' => 'publish');
$the_query = new WP_Query($args);
$counter=1;
while ($the_query->have_posts()) : $the_query->the_post();?>
<li <?php if($counter==6){echo "class='last'";}?>>
<div id="normal">
<a href="<?php the_permalink(); ?>">
<?php $values = get_post_custom_values("Featured Image"); ?>
<img src="<?php echo $values[0];?>" /></a>
</div>
<?php /*?><div id="mob">
<?php $values_m = get_post_custom_values("mobile Link"); ?><a href="<?php echo $values_m[0];?>">
<?php $values = get_post_custom_values("Featured Image"); ?>
<img src="<?php echo $values[0];?>" /></a>
</div><?php */?>
<p class="title"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></p>
<?php /*?><p class="mob_title"><?php $values_m = get_post_custom_values("mobile Link"); ?><a href="<?php echo $values_m[0];?>">
<?php the_title(); ?>
</a></p><?php */?>
<p>
<?php $values1 = get_post_custom_values("views");?>
<?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>
|
<?php if(function_exists('the_views')) { the_views(); } ?>
</p>
</li>
<?php $counter++; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
Thanks.
No comments:
Post a Comment