• I’m trying to format certain posts before displaying them on a page. Right now I’m simply using the the_content() function to output the content of posts so that they appear exactly the way they were entered (I want to have someone type three lines in a post: a date, location and room number. I have a page that loops through posts in a particular category and displays each post in a table on a page.) The problem is I want to format the output, like have a “Date: ” label followed by the first line of the post, then on the next line a “Location: ” label, followed by the second line of the post, etc. Problem is the only way I know what part of the post is the date is that it’s followed by a line break, which I can’t figure out how to search for since it looks like get_the_content() strips the linebreaks out of the post content. Is there any other wordpress function that returns the content exactly the way it was entered by the poster (capturing line breaks and all), so I can use a string search function on it to look for linebreaks? If so, would I look for \n or &nbsp, etc.? Thanks for any suggestions!

  • The topic ‘How to search for line breaks in post content’ is closed to new replies.