How do you get formatted content of a post using the WordPress API?

Post’s object field contains raw content as it is stored in database. This should format it to how it appears when retrieved with template tags:

$content = apply_filters('the_content', $content);

This filters runs number of formatting functions, including shortcodes parsing. Something close to this:

>>>>>   the_content
8   (object) WP_Embed -> run_shortcode (1) 
    (object) WP_Embed -> autoembed (1) 
10  wptexturize (1) 
    convert_smilies (1) 
    convert_chars (1) 
    wpautop (1) 
    shortcode_unautop (1) 
    prepend_attachment (1) 
11  capital_P_dangit (1) 
    do_shortcode (1) 

Leave a Comment