Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wordpress the_content parse outside the loop

the_content() function parsed the text from the db in such a way that paragraphs for example will get <p> tag around them. However, when you retrieve the content outside of the loop you cannot use the_content(). I'm currently using $db_object->post_content. However, doing it this way, the text is not being parsed like with the_content(), so by adding <p>. Is just gives the plain text.

Is there a function in PHP, or does anyone know a equivalant function that parses the text the same way the_content() does and output the correct tags around the text.

Thnx in advance.

like image 909
Redox Avatar asked Sep 06 '12 17:09

Redox


1 Answers

Yes. Use

$content = $db_object->post_content;
$content = apply_filters( 'the_content', $content );
like image 168
stealthyninja Avatar answered Sep 30 '22 12:09

stealthyninja