Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
Created December 18, 2013 06:07
Show Gist options
  • Save ChrisCree/8017959 to your computer and use it in GitHub Desktop.
Save ChrisCree/8017959 to your computer and use it in GitHub Desktop.
Add an odd/even post class to archive pages in Genesis (or WordPress generally) for styling purposes.
<?php
// don't copy openting php tag
// Add odd/even classes to blog archives
add_filter ( 'post_class' , 'wsm_oddeven_post_class' );
global $current_class;
$current_class = 'odd';
function wsm_oddeven_post_class ( $classes ) {
global $current_class;
$classes[] = $current_class;
$current_class = ($current_class == 'odd') ? 'even' : 'odd';
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment