Created
April 13, 2016 07:19
-
-
Save priyabratary/beb0e9b005584eb3f7d5449e9c56b646 to your computer and use it in GitHub Desktop.
unique id each post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $post_counter = 0; // start a counter before the loop ?> | |
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php $post_counter++; // increment the counter for each post ?> | |
<article <?php post_class(); ?> id="layout-<?php echo $post_counter; ?>"> | |
<?php if ( $post_counter <= 3 ) : ?> | |
// display something only for the third post in the loop | |
<?php endif; ?> | |
// the loop content goes here | |
</article> | |
<?php endwhile; ?> | |
<?php else : ?> | |
// not found page | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment