Skip to content

Instantly share code, notes, and snippets.

@sarahmonster
Created November 25, 2016 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarahmonster/1792aa400708d8edbd2fabbc4f28083f to your computer and use it in GitHub Desktop.
Save sarahmonster/1792aa400708d8edbd2fabbc4f28083f to your computer and use it in GitHub Desktop.
Excerpt customisation
/*
* Let's customize our excerpt a bit, so it looks better
* First we decrease the default excerpt length, then
* we give it a proper hellip for the more text.
*/
function themeslug_custom_excerpt_length( $length ) {
return 27;
}
add_filter( 'excerpt_length', 'themeslug_custom_excerpt_length', 999 );
function themeslug_custom_excerpt_more($more) {
$more_link = '<span class="read-more">';
$more_link .= '<a class="more-link" href="' . esc_url( get_the_permalink() ) . '" rel="bookmark">';
$more_link .= sprintf(
wp_kses( __( 'Read more %s', 'themeslug' ), array( 'span' => array( 'class' => array() ) ) ),
the_title( '<span class="screen-reader-text">"', '"</span>', false )
);
$more_link .= '</a></span>';
return '&hellip; ' . $more_link;
}
add_filter( 'excerpt_more', 'themeslug_custom_excerpt_more' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment