Last active
August 29, 2015 14:11
-
-
Save srikat/f632ff1f2834820dbcdd to your computer and use it in GitHub Desktop.
How to use Genesis Grid Loop plugin on a specific Category and show Excerpts. http://sridharkatakam.com/use-genesis-grid-loop-plugin-specific-category-show-excerpts/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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>'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //* 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