0

I've just started working with Wordpress and I need to get the content of a post with all filters applied (eg. the html content of the post as appears on the page after all the available filters have been applied).

I am using this:

$post = get_post($postid, OBJECT, 'display');
echo $post->post_content;

I am getting content like this, including some tags added in by the visual composer plugin:

...[vc_row][vc_column][vc_column_text]Lorem ipsum[/vc_column_text][/vc_column][/vc_row]...

Looks like this is the database value of that field and no filters are being applied.

Could anyone help me get the post_content (with all filters applied) of a post knowing the post id?

2

You need to pass that through the the_content filter like so:

echo apply_filters( 'the_content', $post->post_content );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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