Archived topic
Excerpt Limit & Read More button Not Working
5 replies · Started by Alirio on June 24, 2021
I might've missed the solution on the support forum.
I am redoing my website starting with a fresh database. Installed the Marketer theme. Imported all my posts. But, the front page with all the blog posts isn't limiting the excerpt (set to 20) and adding the Read more button/link except for one blog post card out of around 16 posts.
Any help is appreciated.
Thank you.
Rio
Hi Alirio,
Could you go to the post editor and check if you are using custom excerpt?
https://www.screencast.com/t/69ssis1NpH
Let me know :)
Oh I see. Yes, I am. I just removed the custom excerpt and the Read more button appeared.
How can I insert a button with a custom excerpt?
Thank you, Ying.
You can try this PHP snippet to force the Read more button to appear with a custom excerpt.
https://docs.generatepress.com/article/activating-read-custom-excerpt/#read-more-button
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know :)
Perfect. Thank you!!! I also added a class to it.
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <a class="read-more" href="%2$s">%3$s</a>',
$excerpt,
get_permalink(),
__( 'Read more →', 'generatepress' )
);
}
return $output;
}
Nice!
You are welcome :)