By default, WordPress skips all of the excerpt_length
and excerpt_more
filters when the custom excerpt is used.
If you would like to use the read more links or read more buttons with custom excerpt, we can use the following snippets:
Read more text
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' ); function tu_excerpt_metabox_more( $excerpt ) { $output = $excerpt;
if ( has_excerpt() ) { $output = sprintf( '%1$s <a href="%2$s">%3$s</a>', $excerpt, get_permalink(),
__( 'Read more', 'generatepress' ) ); }
return $output; }
Read more button
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' ); function tu_excerpt_metabox_more( $excerpt ) { $output = $excerpt;
if ( has_excerpt() ) { $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>', $excerpt, get_permalink(),
__( 'Read more', 'generatepress' ) ); }
return $output; }