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 %3$s',
$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
',
$excerpt,
get_permalink(), __( 'Read more', 'generatepress' )
);
}
return $output;
}