Site logo

Archived topic

force read more button

7 replies · Started by Marco on May 23, 2019

Viewing posts 1–8 of 8

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??

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

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' );

Awesome.

Thanks for sharing!

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

This archived topic is closed to new replies.