Site logo

Archived topic

'Read More' button not showing on blog page with custom excerpts

5 replies · Started by Megan on April 11, 2020

Viewing posts 1–6 of 6

Hi there, I have set custom excerpts for blog posts, however now on the blog page (which is set to display recent posts), the read more button has disappeared.

Having looked through the support forum, and your documentation pages, I have tried to fix this by adding the following to simple CSS, but it does not work:

add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;

if ( has_excerpt() ) {
$output = sprintf( '%1$s <p class="read-more-button-container">%3$s</p>',
$excerpt,
get_permalink(),
__( 'Read more', 'generatepress' )
);
}

return $output;
}

Being that the above does not work, do you have coding which I can add to simple CSS which will reinstate the read more buttons when custom excerpts are enabled?

Thanks :)

Hi, it's not the CSS code.
Instead follow the process like this.
Go to Plugins > Add New
Search Code Snippets Plugin. Install the plugin and Activate
And then Go to Snippets and Click on Add New
Give the name to the New Snippets and Paste the following code and Hit Activate
https://i.imgur.com/sUebs9f.png

add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
	$output = $excerpt;
        $settings = wp_parse_args( 
		get_option( 'generate_blog_settings', array() ), 
		generate_blog_get_defaults() 
	);
	
	if ( has_excerpt() ) {
		$output = sprintf('%1$s <br /><a class="read-more" href="%2$s">%3$s  →</a>',
			$excerpt,
			get_permalink(),
                        wp_kses_post( $settings['read_more'] )
		);
	}
	
	return $output;
}

Thanks for the help, that works now :)

Happy Easter!

Welcome and Happy Easter :)

Thanks Suraj

Welcome :)

This archived topic is closed to new replies.