Add a class to every 2nd post
-
Hey everyone,
Im trying to add a class to every 2nd post I have. I have gone through the forums and none of them seem to work for my theme.
Below is the code im using to display a post on my index.php
I have no loop pages to add anything too.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article"> <header> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'wpbs-featured' ); ?></a> <div class="page-header"><h1 class="h2"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1></div> <p class="meta"><?php _e("Posted", "bonestheme"); ?> <time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_date(); ?></time> <?php _e("by", "bonestheme"); ?> <?php the_author_posts_link(); ?> <span class="amp">&</span> <?php _e("filed under", "bonestheme"); ?> <?php the_category(', '); ?>.</p> </header> <!-- end article header --> <section class="post_content clearfix"> <?php the_content( __("Read more »","bonestheme") ); ?> </section> <!-- end article section --> <footer> <p class="tags"><?php the_tags('<span class="tags-title">' . __("Tags","bonestheme") . ':</span> ', ' ', ''); ?></p> </footer> <!-- end article footer --> </article> <!-- end article -->Hope someone can help!
Thanks!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Add a class to every 2nd post’ is closed to new replies.