Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2016 22:14
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 anonymous/a53df08be1ca85acc8c5e3f7199ffa08 to your computer and use it in GitHub Desktop.
Save anonymous/a53df08be1ca85acc8c5e3f7199ffa08 to your computer and use it in GitHub Desktop.
<?php
/**
* Set up the Grid Loop
* @author Bill Erickson
* @link http://www.billerickson.net/genesis-grid-loop-content/
*
*/
function child_grid_loop_helper() {
genesis_grid_loop( array(
'features' => 0,
'feature_image_size' => 1,
'feature_image_class' => 'alignleft post-image',
'feature_content_limit' => 1,
'grid_image_size' => grid,
'grid_image_class' => 'alignleft post-image',
'grid_content_limit' => 5,
'more' => __( '[Continue reading...]', 'genesis' ),
'posts_per_page' => 12,
) );
}
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_grid_loop_helper' );
/**
* Attach Grid Loop Functions
* @author Bill Erickson
* @link http://www.billerickson.net/genesis-grid-loop-content/
*
*/
function child_switch_content() {
remove_action('genesis_post_content', 'genesis_grid_loop_content');
add_action('genesis_post_content', 'child_grid_loop_content');
add_action('genesis_after_post', 'child_grid_divider');
add_action('genesis_before_post_title', 'child_grid_loop_image');
}
add_action('genesis_before_post', 'child_switch_content');
/**
* Grid Loop Content
* @author Bill Erickson
* @link http://www.billerickson.net/genesis-grid-loop-content/
*
*/
function child_grid_loop_content() {
global $_genesis_loop_args;
if ( in_array( 'genesis-feature', get_post_class() ) ) {
if ( $_genesis_loop_args['feature_image_size'] ) {
printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), genesis_get_image( array( 'size' => $_genesis_loop_args['feature_image_size'], 'attr' => array( 'class' => esc_attr( $_genesis_loop_args['feature_image_class'] ) ) ) ) );
}
the_excerpt();
$num_comments = get_comments_number();
if ($num_commets == '1') $comments = '<span>'.$num_comments.'</span> comment';
else $comments = '<span>'.$num_comments.'</span> comments';
echo '<p class="to_comments"><span class="bracket">{</span><a href="'.get_permalink().'/#comments" rel="nofollow">'.$comments.'</a><span class="bracket">}</span></p>';
}
else {
the_excerpt();
$num_comments = get_comments_number();
if ($num_commets == '1') $comments = $num_comments.' comment';
else $comments = $num_comments.' comments';
echo '<p class="more"><a class="comments" href="'.get_permalink().'/#comments">'.$comments.'</a> <a href="'.get_permalink().'">Read the full article &amp;raquo;</a></p>';
}
}
/**
* Grid Loop Image
* @author Bill Erickson
* @link http://www.billerickson.net/genesis-grid-loop-content/
*
*/
function child_grid_loop_image() {
if ( in_array( 'genesis-grid', get_post_class() ) ) {
global $post;
echo '<p class="thumbnail"><a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'child_thumbnail').'</a></p>';
}
}
/**
* Grid Loop Divider
* @author Bill Erickson
* @link http://www.billerickson.net/genesis-grid-loop-content/
*
*/
function child_grid_divider() {
global $loop_counter, $paged;
if ((($loop_counter + 1) % 2 == 0) && !($paged == 0 && $loop_counter < 2) ) echo '<hr />';
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment