Archived topic
Issue: read more button missing when using excerpt
7 replies · Started by Hans-Gerd on December 31, 2020
Hi,
another issue is related to the "Read more" button: The button is only visible if no text excerpt has been defined. Even if I switch off the option <"Show read more" as button> under Your customisations for ▸ Layout > Blog, the text "Read more" is not displayed.
For example please see here on our development environment: http://test4.haurand.com/tag/belgien/page/14/.
Sorry if this request appears twice now: I had posted the topic about 1 hour ago, however the topic does not appear in the summary. I have done more research in the meantime, so that my first post is no longer up to date.
Thanks for advice
Best regards
Hans-Gerd
Hi there,
if you're using a custom excerpt on the post then this article explains how to add the read more to them:
https://docs.generatepress.com/article/activating-read-custom-excerpt/
Hi David,
thanks a lot - it works perfectly.
Best regards and all the best for 2021
Hans-Gerd
You're welcome - and all the best to you !
Hi there,
could I jump in on this as well?
I've inserted the snipped provided to show the read more button when using custom excerpts. It is working fine for the blog page (archive), however, the read more button is now showing up in the header section that I've made for blog post pages.
See here for reference: https://davidsievers.eu/wp-content/uploads/2021/11/Bildschirmfoto-2021-11-30-um-21.42.32.jpg
Is there any way to keep the button on the blog page, but remove it from single post pages?
Thanks in advance!
Best,
David
Hi David,
Try this instead:
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() && !is_single()) {
$output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
$excerpt,
get_permalink(),
__( 'Read more', 'generatepress' )
);
}
return $output;
}
Let me know :)
Hi Ying!
It worked perfectly, awesome! Thanks :)
Best,
David
You are welcome :)
