Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active April 19, 2019 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/b924a2c6aaa746a477053472e06fc557 to your computer and use it in GitHub Desktop.
Save westonruter/b924a2c6aaa746a477053472e06fc557 to your computer and use it in GitHub Desktop.
Twenty Seventeen: Force content excerpts on archives.
<?php
/**
* Template part for displaying a post, forcing the excerpt template part to be used on archives.
*
* Instructions: Place this file in your twentyseventeen child theme at template-parts/post/content.php
*
* @package Twenty_Seventeen
*/
if ( is_archive() ) {
get_template_part( 'template-parts/post/content', 'excerpt' );
} else {
include get_template_directory() . 'template-parts/post/content.php';
}
@thoatswold
Copy link

This no longer works, as of April 2019 (probably earlier).

My solution is to modify /template-parts/post/content.php as follows (from line 53):
<?php if ( is_single() ) { ?> <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() ) ); } else { ?> <div class="entry-excerpt"> <?php the_excerpt(); }
The above snippet comes directly above wp_link_pages( and replaces the existing content beginning <div class="entry-content">.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment