How to remove headings in excerpts from WordPress Twenty Sixteen Theme

Twenty sixteen is a theme provided by wordpress.org with a modernized take on an ever-popular WordPress layout. The theme provides horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere.

The Problem

Twenty sixteen theme does not show excerpts by default in the home page. To modify the theme to show excerpts, please refer this post.

Now, let’s look at a post content that uses headings.

The excerpt for the above post comes up in the home page as below.

Notice how the header Introduction is part of the excerpt. This is not always desirable and sometimes we want to exclude the headings from the excerpt.


The Solution

Edit the theme via the Theme Editor to remove the headings from excerpts. The steps are as below.

  1. Go to Appearance > Theme Editor
  1. From the right sidebar (Theme Files), open  functions.php
  1. Add the below code at the bottom

Refer this discussion on the WP support forum for the original answer.


Conclusion

Now, the post excerpt is displayed without the headings as below.

Leave a Reply

Your email address will not be published. Required fields are marked *