Archived topic
Remove "..." in excerpt from the archive pages
5 replies · Started by Quan on November 28, 2020
Hello,
I tried adding the following code but It lost the excerpt section.
.entry-summary p:not(.read-more-container) {
display: none;
}
If I want to delete “…” but keep the read more button and the excerpt section, what should I do? I just want to remove the “…” character.
Hi there,
Give this PHP snippet a shot:
add_filter( 'generate_excerpt_more_output', function() {
return sprintf(
' <a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s">%3$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
__( 'Read more', 'generatepress' ),
sprintf(
/* translators: Aria-label describing the read more button */
_x( 'More on %s', 'more on post title', 'generatepress' ),
the_title_attribute( 'echo=0' )
)
);
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Thank you!
I want to use "Read more" as a button, not a text link. Can you help me?
Try this filter instead:
add_filter( 'generate_excerpt_more_output', 'lh_generate_blog_read_more_button' );
add_filter( 'generate_content_more_link_output', 'lh_generate_blog_read_more_button' );
function lh_generate_blog_read_more_button( $output ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'read_more_button' ] ) {
return $output;
}
return sprintf( '%5$s<p class="read-more-container"><a title="%1$s" class="read-more button" href="%2$s">%3$s%4$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump','#more-' . get_the_ID() ) ),
wp_kses_post( $settings['read_more'] ),
'<span class="screen-reader-text">' . get_the_title() . '</span>',
'generate_excerpt_more_output' == current_filter() ? '' : ''
);
}
Thank you for the great support!
No problem :)