Archived topic
How to display the excerpt in a blog post without showing "Read More" button?
7 replies · Started by Dominic on April 10, 2021
Hi,
I used this code to add the "read-more" button to the blog post feed on my homepage and this example to add the excerpt above the featured image in my blog posts.
The problem is that the "read more" button also displays in the blog post. How can i keep the "read more" button in the homepage, but remove it in the actual blog posts?
Thanks very much,
Dom
Hi there,
can you share a link to a post so we can see what the issue is
Hi David,
I'm working locally just now, so can't send a link i'm afraid, but here is a pic of the home screen with the "read more" button.
And here's an image of a log post which also has the "read more" button after i used the code i linked to above to add the excerpt after the meta data.
I assume it's some sort of conflict between the 2 pieces of code i used.
Thanks,
Dom
Are you displaying the excerpt on the single post ?
Yes
In the code you used to display the read more button - this line:
if ( has_excerpt() ) {
Change to:
if ( has_excerpt() && !is_single() ) {
This should remove the button from the single post.
Thanks David,
That worked a treat, you're a star!
Much appreciated,
Dom
Glad to hear that!