[WordPress] How to show excerpt instead of full post in Twenty Seventeen?

How to show excerpt instead of full post in Twenty Seventeen?

The new default theme "Twenty Seventeen" was added in WordPress 4.7. If you do not have one, you can install Twenty Seventeen from WP dashboard.

If you display the recent posts on your front page, full post will be displayed instead of excerpt.

In this case, you can show excerpt instead of full post by editing the content.php file under the folder  /wp-content/themes/twentyseventeen/template-parts/post/. Of course, it's recommended you should create a child theme before proceeding with the following change.

Please find the following code:

<div class="entry-content">
<?php
/* translators: %s: Name of current post */
the_content( sprintf(
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
get_the_title()
) );

wp_link_pages( array(
'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
'after'       => '</div>',
'link_before' => '<span class="page-number">',
'link_after'  => '</span>',
) );
?>
</div><!-- .entry-content -->

And then, replace it with the following code:

<div class="entry-content">
<?php
if ( is_single() ) :
/* translators: %s: Name of current post */
the_content( sprintf(
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
get_the_title()
) );

wp_link_pages( array(
'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
'after'       => '</div>',
'link_before' => '<span class="page-number">',
'link_after'  => '</span>',
) );
else :

the_excerpt( sprintf(
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
get_the_title()
) );

wp_link_pages( array(
'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
'after'       => '</div>',
'link_before' => '<span class="page-number">',
'link_after'  => '</span>',
) );
endif;
?>
</div><!-- .entry-content -->

Now you will see excerpt instead of the full content of posts in your front page or other archive pages.

 

You might also want to read:


Leave a Comment