Skip to content

Instantly share code, notes, and snippets.

@5ally

5ally/HOWTO.md Secret

Last active July 1, 2019 23:12
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 5ally/72d590e0a041acb6bd0857e8aed0c6c1 to your computer and use it in GitHub Desktop.
Save 5ally/72d590e0a041acb6bd0857e8aed0c6c1 to your computer and use it in GitHub Desktop.

For the Twenty Nineteen theme (tested on version 1.4):

The homepage by default uses the index.php template, and in that file, the posts are displayed like this:

// Load posts loop.
while ( have_posts() ) {
	the_post();
	get_template_part( 'template-parts/content/content' );
}

And in template-parts/content/content.php, you'd see the following:

the_content(
	sprintf(
		wp_kses(
			/* translators: %s: Name of current post. Only visible to screen readers */
			__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentynineteen' ),
			array(
				'span' => array(
					'class' => array(),
				),
			)
		),
		get_the_title()
	)
);

And that displays the full post content.

If you want to show just the post excerpt, change the above code to this:

if ( is_singular() ) {
	the_content(
		sprintf(
			wp_kses(
				/* translators: %s: Name of current post. Only visible to screen readers */
				__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentynineteen' ),
				array(
					'span' => array(
						'class' => array(),
					),
				)
			),
			get_the_title()
		)
	);
} else {
	the_excerpt();
}

That should work, but you might want to create a child theme so that your modification wouldn't be wiped when you update Twenty Nineteen.

@GreenGablesFan
Copy link

Hi, I just checked the directory /wp-content/themes/twentyseventeen/template-part/post/ but don't see a file called content.php. Is there a way to reinstall this theme if the file is missing for whatever reason?

@5ally
Copy link
Author

5ally commented Jul 1, 2019

@GreenGablesFan, see the updated HOWTO.md.

And I suggest you to write your own answer for that question.

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