[Resolved] Remove “…” in excerpt from the archive pages

Home Forums Support [Resolved] Remove “…” in excerpt from the archive pages

Home Forums Support Remove “…” in excerpt from the archive pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1555844
    Quan

    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.

    #1556928
    Leo
    Staff
    Customer Support

    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/

    #1557125
    Quan

    Thank you!

    I want to use “Read more” as a button, not a text link. Can you help me?

    #1557298
    Leo
    Staff
    Customer Support

    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() ? '' : ''
    	);
    }
    #1557529
    Quan

    Thank you for the great support!

    #1559144
    Leo
    Staff
    Customer Support
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.