Skip to content

Instantly share code, notes, and snippets.

@surefirewebserv
Created May 2, 2013 18:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save surefirewebserv/5504412 to your computer and use it in GitHub Desktop.
Save surefirewebserv/5504412 to your computer and use it in GitHub Desktop.
Much Simpler Grid Loop. Takes the post class and adds the column class to it. Also takes the first x posts and removes that class, which poses as a "featured" type of post. No crazy manipulation, just messing with classes and adding the right size images... Blog Post To come...
<?php
add_action('genesis_before_post_title', 'sfws_homepage_teaser_image');
/**
* Adds Images to Posts in Grid
*
* Takes the amount of posts and applies the right size image, whether it's a featured post or a grid block post.
*
* @category Grid Loop
* @author Jonathan Perez, SureFireWebServices <jperez@surefirewebservices.com>
* @version 1.0
* @link http://surefirewebservices.com
*/
function expose_homepage_teaser_image() {
global $loop_counter; //global post counter
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
if ($loop_counter >= 2) { //Everything after the first 2 posts
printf( '<p><a href="%s">%s</a></p>', get_permalink(), genesis_get_image( array( 'format' => 'html', 'size'=> 'Featured' ) ) );
} else {
printf( '<p><a href="%s">%s</a></p>', get_permalink(), genesis_get_image( array( 'format' => 'html', 'size'=> 'grid-featured' ) ) );
}
}
add_filter('post_class', 'sf_post_class');
/**
* Add post class filter
*
* Uses the column classes to make a grid.
*
* @category Grid Loop
* @author Jonathan Perez, SureFireWebServices <jperez@surefirewebservices.com>
* @version 1.0
* @link http://surefirewebservices.com
*/
function sf_post_class($classes) {
global $loop_counter; // Post Counter
if ($loop_counter >= 2) { // Everything after the first 2 posts.
$classes[] = 'one-third';
}
if ($loop_counter % 3 == 1) {
$classes[] .= 'last '; //Add Last class to every 3rd post.
}
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment