displaying the first n lines of a post
-
I’m setting up my Search Results page and I don’t want the full content of a post being displayed. An excerpt only.
For example,
date – Title
line1
line2
line3date – Title
line1
line2
line3I’m putting wordpress together for a client, so there is no guarantee that an “excerpt” will be entered for every post.
Basically I check if an excerpt exists. If it does, print it, if it doesn’t print out the first ‘n’ lines of the post.
My question is, is there a way to print out the first ‘n’ lines of a post? Either a wordpress solution or a random php solution would be fine.
Note, using substr(string,0,[max characters]) isn’t a good solution because what if the post starts off with a list? It could end up being many lines before it reaches ‘max characters’.
Hope I made sense. Thanks in advance.
- The topic ‘displaying the first n lines of a post’ is closed to new replies.