Site logo

Archived topic

Read More button after excerpt

7 replies · Started by Stella on August 18, 2018

Viewing posts 1–8 of 8

Hi All,

I have followed the link below to add the PHP to bring the read more button back.

https://docs.generatepress.com/article/activating-read-custom-excerpt/

And the read more button successfully returned.

However, I have changed the size of the buttons using CSS below, but read more buttons from those posts with the custom excerpt are not applied.

.read-more-container {
text-align: center;
}
.read-more-container a {
display: block;
}
.button {
border-radius: 1px;
padding: 13px
}

Could you please help? Thank you!

Hi there,

Any chance you can link us to the site in question?

You can edit the original topic and use the private URL field.

Let me know :)

Hi Leo,

I have added the website link. Thank you!!

I'm not quite sure what you mean?

The page you linked is using WP Show Posts and the CSS above applied?

The link is the home page with GP only - PHP and CSS above applied.

And it has two posts: Test Post and Test Post 2

The Test Post has the read more button fully customised with the CSS above applied.

On the other hand, the Test Post 2 has the manual excerpt and the read more button disappeared.
I used the PHP from the link above to bring the read more button back.
However, the CSS is not applied on the read more button anymore on this particular posts with the manual excerpt.

My question is how to customise the read more button even with the manual excerpt?

Can you try this for your PHP snippet?

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-container"><a class="button" href="%2$s">Read more</a></p>',
			$excerpt,
			get_permalink()
		);
	}	
	return $output;
}

Let me know :)

Perfect! It worked. Thank you very much Leo!

No problem :)

This archived topic is closed to new replies.