Archived topic
Display manual excerpt in a blog post
3 replies · Started by Quentin on November 30, 2022
Hello
I would like to display the manual excerpts of my blog posts, in my blog posts (for example above the Title of the post) but I can't find the option in Customize>Layout>Blog (there are options for the excerpt only for archive, not for single posts).
Here is one of the blog posts : https://staging-darwinnutritionfr-dev.kinsta.cloud/meilleurs-enzymes-digestives/
I have no "read more" in this post
The only plugins I have are Generatepress, Generatepress Premium, Yoast and WP show post.
Thanks for you help
Quentin
Hi there,
Excerpts are only displayed in the archives by default.
If you want o display just the Manual ( not auto ) excerpt on the single post before the title, then add this PHP Snippet to your site:
add_action('generate_before_entry_title', function(){
if ( is_single() && has_excerpt() ) {
?>
<span class="entry-subtitle"><?php echo get_the_excerpt(); ?></span>
<?php
}
});
How to add PHP:
https://docs.generatepress.com/article/adding-php/
It works, thank you !
Glad to hear that!