Wordpress auto excerpts from post content?
Posted
by Scott B
on Stack Overflow
See other posts from Stack Overflow
or by Scott B
Published on 2010-03-09T02:13:57Z
Indexed on
2010/03/09
2:21 UTC
Read the original article
Hit count: 315
I'm trying to create an auto generated post excerpt from the current page's post content using a function in my theme's header file. The post excerpt will be used as the page's meta description. Can someone give me an idea of how you might go about this once you've got the post content into a string variable?
The somewhat tricky part is that, in order to predict a viable stopping point for the post excerpt, I'd like to specify that the cutoff point be the end of the first paragraph of text.
And for that reason, it does not make sense to load the entire post content into the string I'm using. Can I grab the first paragraph without having to load the entire post content string?
And I'm not certain how to test for that in php. Would regex be the only way?
© Stack Overflow or respective owner