[Resolved] force read more button

Home Forums Support [Resolved] force read more button

Home Forums Support force read more button

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #909112
    Marco

    Hello
    I’m showing my posts in some grid view with a summary and “continue reading…” button – I’ve some post where the summary is actually too short so WP is not showing a read more button – for layout consistency I’d like to have that read more button on ALL posts – how can I force WP to show the button all the time??

    #909140
    Leo
    Staff
    Customer Support

    Hi there,

    Can you try this snippet here and see if it works?
    https://docs.generatepress.com/article/activating-read-custom-excerpt/#read-more-button

    Let me know 🙂

    #909144
    Marco

    Thanks Leo – just tried that before you responded – it doesn’t seem to work – has_excerpt() is always false??

    #909149
    Leo
    Staff
    Customer Support
    #909158
    Marco

    Thanks again Leo – the following two filter will do the trick as well:

    	/* Filter - Remove default 'excerpt more'
    	---------------------------------------------------------------------------- */
    	function themeprefix_excerpt_more( $more ) {
    		return '';
    	}
    	add_filter('excerpt_more', 'themeprefix_excerpt_more', 21 );
    
    	/* Filter - Add 'read more' to custom excerpt
    	---------------------------------------------------------------------------- */
    	function themeprefix_get_the_excerpt( $excerpt ) {
    		$output = $excerpt;
    
    		$output = sprintf(
    			'%1$s <p class="read-more-container"><a class="button read-more" href="%2$s" title="">%3$s</a></p>',
    			$excerpt,
    			get_permalink(),
    			__( 'Continue Reading', 'plugin' )
    		);
    
    		return $output;
    	}
    	add_filter( 'get_the_excerpt', 'themeprefix_get_the_excerpt' );
    #909163
    Leo
    Staff
    Customer Support

    Awesome.

    Thanks for sharing!

    #950732
    Pierre-Etienne

    Hi, I would like to do the same thing then Marco, can someone could tell me where I have to paste the code he publish ? thank you

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