Skip to content

Instantly share code, notes, and snippets.

@About2git
Forked from srikat/functions.php
Created February 13, 2015 21:24
Show Gist options
  • Select an option

  • Save About2git/0c2325548b3c370d1f48 to your computer and use it in GitHub Desktop.

Select an option

Save About2git/0c2325548b3c370d1f48 to your computer and use it in GitHub Desktop.
How to use Genesis Grid Loop plugin on a specific Category and show Excerpts
/**
* Grid Loop on 'Category 1' category archive
* Customized by Sridhar Katakam
*
* @author Bill Erickson
* @link https://github.com/billerickson/Genesis-Grid/wiki/Home
*
* @param bool $grid, whether to use grid loop
* @param object $query, the WP Query
* @return bool
*/
function sk_grid_loop_on_specific_category( $grid, $query ) {
if ( is_category( 'category-1' ) ) {
$grid = true;
}
return $grid;
}
add_filter( 'genesis_grid_loop_section', 'sk_grid_loop_on_specific_category', 10, 2 );
/**
* Use Excerpts for Features and Teasers in Grid Loop
* Customized by Sridhar Katakam
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/full-content-features-in-grid-loop
*
* @param string $option
* @return string $option
*/
function sk_excerpts_for_features_and_teasers( $option ) {
if ( in_array( 'feature', get_post_class() ) || in_array( 'teaser', get_post_class() ) )
$option = 'excerpts';
return $option;
}
add_filter( 'genesis_pre_get_option_content_archive', 'sk_excerpts_for_features_and_teasers' );
//* Modify the length of post excerpts on 'Category 1' category archive
add_filter( 'excerpt_length', 'sp_excerpt_length' );
function sp_excerpt_length( $length ) {
if ( ! is_category( 'category-1' ) ) {
return;
}
return 250; // pull first 250 words
}
//* Modify the Excerpt read more link on 'Category 1' category archive
add_filter('excerpt_more', 'new_excerpt_more');
function new_excerpt_more($more) {
if ( ! is_category( 'category-1' ) ) {
return;
}
return '... <a class="more-link" href="' . get_permalink() . '">Read more</a>';
}
//* Show Featured images above Post titles on 'Category 1' category archive
add_action ( 'genesis_entry_header', 'sk_featured_image', 9 );
function sk_featured_image() {
if ( ! is_category( 'category-1' ) || ! has_post_thumbnail() ) {
return;
}
$image_args = array(
'size' => 'full',
);
$image = genesis_get_image( $image_args );
if ( $image ) {
echo '<a href="' . get_permalink() . '">' . $image .'</a>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment