Genesis Grid – Change length of content in grid

<?php
/**
* Grid Content
* Change the number of words in excerpt if in the grid loop
*/
function be_grid_content() {
// First, we make sure we're in the grid loop.
if( ! apply_filters( 'is_genesis_grid_loop', false ) )
return;
// Change length if teaser
if( in_array( 'teaser', get_post_class() ) )
$length = 20;
else
$length = 55;
echo '<p>' . wp_trim_words( get_the_excerpt(), $length ) . '</p>';
// Remove default content so we don't get both
remove_action( 'genesis_post_content', 'genesis_do_post_content' ); // For Genesis 1.x
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); // For Genesis 2.x
}
add_action( 'genesis_post_content', 'be_grid_content', 9 ); // for Genesis 1.x
add_action( 'genesis_entry_content', 'be_grid_content', 9 ); // For Genesis 2.x
view raw archive.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk