dimanche 28 décembre 2014

How to force excerpts / teasers in the loop


When I'm in "the loop" (archive pages etc.) how do I force teasers / excerpts for all articles, regardless of whether they contain the <!--more--> tag or not?


Details:


I'm starting off of the _s template which displays blog post content using the content.php template in which it calls the_content() function. This function inspects the post and tries to find the <!--more--> tag in. If it finds one, it returns a teaser and a read more link, if it doesn't it simply outputs the whole post.


I'd like to keep the first part, i.e. respect the <!--more--> tag if the content author used it, but if he/she forgot it I want to automatically display the teaser / excerpt anyway (something like the first paragraph or two).


What is the best way to do this? There is a the_content filter but e.g. the read more customization text doesn't come into it. What would you recommend?





Aucun commentaire:

Enregistrer un commentaire