Last active
August 29, 2015 14:21
-
-
Save MatRouault/04c76455853a5659c136 to your computer and use it in GitHub Desktop.
Custom excerpt length
This file contains 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
echo '<p>' . wp_trim_words( get_the_excerpt(), 25 ) . '</p>'; | |
/** | |
* Grid Content | |
* Change the number of words in excerpt if in the grid loop | |
*/ | |
function gst_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 class="more-link" href="' . get_permalink() . '">Continue Reading</a>'; | |
// Remove default content so we don't get both | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
} | |
add_action( 'genesis_entry_content', 'gst_grid_content', 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment