WP post excerpt not working on the WordPress Twenty Fifteen theme?
The post excerpt of wordpress is very useful to display the highlight or the summary of a post, this can help us to turn our WP blogs and our websites to be more readable and convenient to the end users.
Unfortunately I’ve found that the post excerpt is not working on my Twenty Fifteen theme of my WordPress websites, searching around about this issue shows me this might be a bug with the Twenty Sixteen, Twenty Seventeen, Twenty Nineteen and all other versions of the great Twenty X themes.
In order to solve this and to add the excerpt section of your WP posts in the home page, categories, tags etc .. I had to get into the source code of the theme. Basically I don’t like to change the source code of my theme, but if i have to do so I usually change the functions.php by adding a filter.
If the excerpt section of the post is empty, the code above can also display a number of chars from the original post, in order to do so just set the num_of_chars variant to the number of chars you want to display (default is 100).
Here are the stages to add the post excerpt section to your WP Twenty X themes:
1) Go to Appearance->Theme Editor.
2) Open the function.php file by clicking on the ‘Theme Functions (functions.php)’.
3) Add this code to the end of the functions.php file:
Now the functions.php should look like:
That’s it 🙂
That’s it, from now on the excerpts of your posts will be displayed in the home page, categories and in the tags of your wordpress website / blog.