Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Forked from billerickson/gist:2040968
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/118ca91a1d3b1a19d534 to your computer and use it in GitHub Desktop.
Save wpsmith/118ca91a1d3b1a19d534 to your computer and use it in GitHub Desktop.
PHP: Query Post Class
<?php
add_filter( 'post_class', 'wps_query_post_class' );
/**
* Archive Post Class
* @since 1.0.0
*
* Breaks the posts into three columns
* @link http://www.billerickson.net/code/grid-loop-using-post-class
*
* @param array $classes
* @return array
*/
function wps_query_post_class( $classes ) {
$classes[] = 'one-third';
global $wp_query;
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 )
$classes[] = 'first';
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment