I wanted to make the excerpt only display second or third paragraph.

I need to know. How can I make the_excerpt() only display second or third paragraph and limit the length of the except.

  • Want to add custom limit to your content ? – Pratik Patel Jan 4 '19 at 8:35
  • What if there are other things in the post? Images, tables, and so on? How is the "second paragraph" defined exactly? – Krzysiek Dróżdż Jan 4 '19 at 9:58

You can explode the content of excerpt by dot. For example:

$text = "Morbi consequat tempor augue. Nec fringilla eros auctor scelerisque. Etiam in ullamcorper tellus. Sed ac dui rutrum.";
$pieces = explode(".", $text);
echo $pieces[1]; // get second sentence = Nec fringilla eros auctor scelerisque

Maybe this can help you.

  • Why do you get second sentence? The question is about paragraphs, not sentences. Also... Your code doesn't change output of the_excerpt() function, but explodes some constant string... – Krzysiek Dróżdż Jan 4 '19 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.