Wordpress the_content parsing outside the loop

Function

the_content() parsed the text from db so that paragraphs, for example, get the <p> around them. However, when you retrieve content outside of a loop, you cannot use the_content() . I am currently using $db_object->post_content . However, by doing this this way, the text is not parsed, as using the_content() , therefore adding a <p> . Just gives plain text.

Is there a function in PHP or does anyone know an equivalent function that parses the text just like the_content() and outputs the correct tags around the text.

Thnx in advance.

+6
source share
1 answer

Yes. Use

 $content = $db_object->post_content; $content = apply_filters( 'the_content', $content ); 
+11
source

Source: https://habr.com/ru/post/924782/


All Articles