Skip to content

Instantly share code, notes, and snippets.

@katmoody
Created May 17, 2015 02:08
Show Gist options
  • Save katmoody/f0c072ec609334f9fd82 to your computer and use it in GitHub Desktop.
Save katmoody/f0c072ec609334f9fd82 to your computer and use it in GitHub Desktop.
Customize Genesis Grid Loop for Excerpt, with dual excerpt lengths for teaser and features, custom Read More with accessibility added
/**
* Change the number of words in excerpt if in the grid loop and customize READ MORE, add accessibility
*/
function kat_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 = 25;
else
$length = 55;
echo '<p>' . wp_trim_words( get_the_excerpt(), $length ) . '</p>';
// Display more link
// echo '<a rel="nofollow" class="more-link" href="' . get_permalink() . '">Continue Reading</a>';
echo '<p class="more-link"><a href="'. get_permalink() .'">' . __( 'Read more', 'genesis' ) . '<span class="screen-reader-text"> ' . __( 'about' ) . " " . get_the_title() . "</span></a></p>";
// Remove default content so we don't get both
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
}
add_action( 'genesis_entry_content', 'kat_grid_content', 9 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment