Posted By

curtismchale on 08/13/10


Tagged

wp postclass


Versions (?)

Alternate post_class();


 / Published in: PHP
 

  1. // alternates odd - even post class on post_class();
  2. add_filter ( 'post_class' , 'sfn_alternate_post_class' );
  3. global $current_class;
  4. $current_class = 'odd';
  5.  
  6. function sfn_alternate_post_class ( $classes ) {
  7. global $current_class;
  8. $classes[] = $current_class;
  9.  
  10. $current_class = ($current_class == 'odd') ? 'even' : 'odd';
  11.  
  12. return $classes;
  13. }

Report this snippet  

You need to login to post a comment.