I'm accessing a page content from outside WordPress, in a different webpage. Everything runs fine, I'm using this:

$page_id = 300;
$data = get_page($page_id);    
echo $data->the_content;

However, the content is different from what WordPress would output normally. For example, paragraphs which are separated by blank lines in source come just like that, without <p> tags. How can I get the content from a page in the same way that WordPress would print it? Should I apply some other filter or use another function to process the text?

1 Answer 1


Indeed! It's a filter called 'the_content', to which numerous other functions are hooked such as the one that turns Wordpress into WordPress, oembeds, and the p tag wrapping

echo apply_filter('the_content',$data->the_content);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.