Archived topic
Disable 'Read More' button for Excerpts in some cases
5 replies · Started by Soumya on August 3, 2022
Hi,
I just installed Generatepress a few weeks ago and currently testing changes on the staging site before moving to the live server by the end of this week. I was using Elementor previously and currently I am in the process of removing it completely.
Since I customised the Archive pages, I added the code for 'Read More' button (https://docs.generatepress.com/article/activating-read-custom-excerpt/#read-more-button) . I also customised my post hero.
Post Hero is Currently Title -> Excerpt -> Featured Image. https://share.getcloudapp.com/5zurELZY
Now the problem is that I don't want the 'Read More' button under the excerpt here. But I need the Read More button under the Excerpt in the Archive pages. Is there any option to disable it only here?
Thank you in advance.
Regards,
Soumya Nambiar
Hi there,
can i see a post where the Read More button is in the hero ?
I had attached the image before.
https://share.getcloudapp.com/5zurELZY
This is happening for all posts.
Ok, the code you used to add the read more, change it to:
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;
}
Thank you so much. This worked.
Glad to hear that!