Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created March 29, 2016 21:39
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 billerickson/5f77a5f5f1199183f515bc11f37ab78b to your computer and use it in GitHub Desktop.
Save billerickson/5f77a5f5f1199183f515bc11f37ab78b to your computer and use it in GitHub Desktop.
<?php
/**
* Archive Post Class
* @since 1.0.0
*
* Breaks the posts into two columns
* @link http://www.billerickson.net/code/grid-loop-using-post-class
*
* @param array $classes
* @return array
*/
function be_archive_post_class( $classes ) {
global $wp_query;
if( ! $wp_query-&gt;is_main_query() )
return $classes;
// Don't run on single posts or pages
if( is_singular() )
return $classes;
$classes[] = 'one-half';
global $wp_query;
if( 0 == $wp_query-&gt;current_post || 0 == $wp_query-&gt;current_post % 3 )
$classes[] = 'first';
return $classes;
}
add_filter( 'post_class', 'be_archive_post_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment