Skip to content

Instantly share code, notes, and snippets.

@carasmo
Created February 5, 2017 16:39
Show Gist options
  • Save carasmo/d4e282f018f720d2eeb9e752b6fb1948 to your computer and use it in GitHub Desktop.
Save carasmo/d4e282f018f720d2eeb9e752b6fb1948 to your computer and use it in GitHub Desktop.
<?php
//don't add
/*
* Add Genesis one-third (3 col) class to the article.post in archives
* in the main query. Uses Genesis specific filter
* instead of WordPress's post_class filter
* to do the same thing 'cause why not!
*
*/
function themeprefix_add_column_grid_entry_archive( $attributes ) {
global $wp_query;
//is the main query and is not singular
if( $wp_query->is_main_query() && ! is_singular() ) {
$attributes['class'] .= ' one-third';
if( 0 == $wp_query->current_post % 3 ) {
$attributes['class'] .= ' first';
}
}
return $attributes;
}
add_filter( 'genesis_attr_entry', 'themeprefix_add_column_grid_entry_archive' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment