Skip to content

Instantly share code, notes, and snippets.

@webmasterninjay
Created March 31, 2015 17:56
Show Gist options
  • Save webmasterninjay/e29b755e5ea568e67f5d to your computer and use it in GitHub Desktop.
Save webmasterninjay/e29b755e5ea568e67f5d to your computer and use it in GitHub Desktop.
<?php
add_filter('post_class', 'jay_grid_view_post_class');
function jay_grid_view_post_class( $classes ) {
if( is_post_type_archive( $posttype ) ):
$columns = 3;
$classes[] = 'one-third';
global $wp_query;
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
$classes[] = 'first';
endif;
return $classes;
}
add_action('pre_get_posts', 'jay_post_items');
function jay_post_items( $query ) {
if( $query->is_main_query() && !is_admin() && is_archive() ) {
$query->set( 'posts_per_page', '9' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment