How can I display post excerpt in the Blog archive?
We’re trying to keep it simple wherever it’s possible. That’s why the blog archive and each card have three simple elements: the featured image, the title, and the meta details. However, if the post excerpt is an important part of your posts, you can easily display it right after the meta by doing this simple change. All you have to do is use this piece of code:
function custom_function_add_blog_excerpt() {
echo '<div class="post__excerpt">' . the_excerpt() . '</div>';
}
add_action ('blog_archive_post_excerpt', 'custom_function_add_blog_excerpt');
There are two options for adding it to your website:
- You can copy it to the functions.php of the child theme. You can find some more details about this right here;
- Install the Code Snippets and add the code through it.
Updated on March 23, 2023