Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was wondering if it was possible to get the first two paragraphs and the feature image in the excerpt.

I currently have the first 100 words, but would like the the first two paragraphs.

What I want to achieve is something like Smashing Magazine, where the first paragraph is one font, and the second is the base, while and image is in-between. (http://smashingmagazine.com)

I know you can do this with the manual excerpt too, but that's way too tedious!

share|improve this question

2 Answers 2

Check out this tutorial: http://jshamsul.com/2012/02/08/wordpress-get-first-paragraph-from-post/

There the author puts all the paragraphs into array. So you could possibly pull out the first, second, thrid... paragraphs from that array.

As for smashingmagazine.com styling the first paragraph. They do it with CSS :first-child pseudo-class like this:

p:first-child {
/* your styles */
}

More info about :first-child - https://developer.mozilla.org/en-US/docs/CSS/:first-child

You could also style the second paragraph with :nth-child like this:

p:nth-child(2) {
/* your styles */
}

More info about :nth-child - https://developer.mozilla.org/en-US/docs/CSS/:nth-child

share|improve this answer

AFAIK, you can only set the number of words that come in the excerpt using the excerpt_length filter. But I found this post worth a read for you, might help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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