Created
November 25, 2016 00:02
-
-
Save sarahmonster/1792aa400708d8edbd2fabbc4f28083f to your computer and use it in GitHub Desktop.
Excerpt customisation
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
/* | |
* 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 '… ' . $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