0

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!

2 Answers 2

1

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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