One fast way to add a grid to one of your archive pages. Let’s say we want all articles for the the tag wordpress to be in three columns. First add a tag-wordpress.php file to your themes directory and put the following code.
/* Let's add grid classes */
add_filter( 'post_class', 'jhts_entry_post_class' );
function jhts_entry_post_class( $classes ){
global $wp_query;
$classes[] = "one-third";
if ( $wp_query->current_post % 3 == 0 ) {
$classes[] = "first";
}
return $classes;
}
genesis();
$wp_query->current_post will give you a number that represents the query result’s current row number. The first resulting post would be 0. The next post would be 1 and so on. We can use this number to determine if the current post should be in the first column in which case we need to add the ‘first’ class to it. The ‘%’ stands for modulus, that gives us the remainder of the division. In this example, anytime the current_post value is divisible by 3, it will return 0…AKA no remainder.
If we wanted the grid to have only two columns we could change ‘one-third’ to ‘one-half’ and change the if statement’s ‘3’ to a ‘2’.
To view your tag page go to http:/yourURLhere.com/tag/wordpress