Archived topic
Add excerpt after headline?
10 replies · Started by Edin on December 8, 2022
I'm trying to add the excerpt after a posts h1 title.
I used this in the hook "generate_after-entre-title":
<div class="excerpt-style"><?php the_excerpt(); ?></div>
It works, but the problem is that it adds the "read more" button at the bottom automatically.
I tried to remove it with the following:
.read-more-button-container {display:none;}
But then ALL the "read more" buttons on the site are removed. I want to keep them on the blog articles list page at least.
What's the best way to do this?
Thanks in advance,
Edin
Hi there,
instead of :
<?php the_excerpt(); ?>
try:
<?php echo get_the_excerpt(); ?>
Hi David,
Thank you, but, unfortunately, that didn't work.
Sorry, wrong thread.
Are you trying to display the manual excerpt ?
Yes, I'm trying to add the excerpt I manually write (in the box below the article editor).
in your hook add:
if ( has_excerpt() ) {
?>
<span class="entry-subtitle"><?php echo get_the_excerpt(); ?></span>
<?php
}
by default the manual excerpt should not show a read more. If it still is, can you leave the code as is and share a link to a post where i can see the issue ?
I added the code, but the read-more button is still there. (see "Private information" for URL and access)
Hi Edin,
Can you check if you have this function added?
https://docs.generatepress.com/article/activating-read-custom-excerpt/#read-more-button
Thank you, Ying. That was indeed the issue.
Thanks,
Edin
You are welcome :)