• Hi,
    I want to use a counter to custom first , second and third post styles in the loop
    I used this code to custom only the first post :

    <?php $i = 1; ?>
    <?php $otherFeaturedPost = new WP_Query(); $otherFeaturedPost->query('showposts=4&offset=0'); ?>
    <?php while ($otherFeaturedPost->have_posts()) : $otherFeaturedPost->the_post(); ?>
    	<?php if($i <= 1) { ?>
    	<a href="#fragment-1"> <?php the_post_thumbnail( array( 'class' => 'emadsss5' )); ?> <span><?php the_title(); ?></span></a>
    	<?php } else { ?>
    	<a href="#fragment-2"> <?php the_post_thumbnail( array( 'class' => 'emadsss5' )); ?> <span><?php the_title(); ?></span></a>
    	<?php } ?>
    <?php $i++; endwhile; wp_reset_query(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • can you clarify the purpose of the code and is it in theme or in plugin? why do you want to count only the first three?
    did you try wp-postviews?

    Can you clarify what problem you are having?

    May I suggest the following change to your code:

    <?php $counter = 1; ?>
    <?php $otherFeaturedPost = new WP_Query(); $otherFeaturedPost->query('showposts=4&offset=0'); ?>
    <?php while ($otherFeaturedPost->have_posts()) : $otherFeaturedPost->the_post(); ?>
    	<a href="#fragment-<?php print $counter; ?>"> <?php the_post_thumbnail( array( 'class' => 'emadsss5' )); ?> <span><?php the_title(); ?></span></a>
    <?php $counter++; endwhile; wp_reset_query(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘want to use acounter to custom first , second and third post in the loop’ is closed to new replies.