How to display excerpts instead of full posts in the category pages (archives) of the WordPress Twenty Sixteen theme?
Find the archive.php file
- Open the WordPress dashboard, then go to Appearance -> Editor, select the archive.php file on the right.
- Click to open the archive.php file
Edit the file to show the excerpts
Find the following line inside archive.php
1 |
while ( have_posts() ) : the_post(); |
inside the loop replace the following line
1 |
get_template_part( 'template-parts/content', get_post_format() ); |
with
1 2 3 |
the_title( sprintf( '<h2 class="archiv-entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); the_excerpt(); |
Click on Update the file at the bottom of the page.
All done.
Excerpts will be shown instead of full post in the category (archive) pages.
The excerpts will be composed of the clickable title and of the first words of the posts.
The Explanation
the_excerpt() function shows the excerpt of the post, showing only the content, so adding a call to the_title() is needed. The replaced call showed all the post calling the related template.
Other solutions
A more clean solution to show the excerpts in a category which includes creating a child theme can be found in this german page.
Creating a child theme in WordPress can be useful because when the Twenty Sixteen theme will be updated you’ll lose your changes.