I tried using
<?php $my_id = 7; $post_id_7 = get_post($my_id); echo $post_id_7->post_content; ?>
based on the documentation here.
The article I’m trying to retrieve has Short Code, which is picked up by a plugin on my site, and then formatted into HTML.
The problem is when I output the post_content to the site, the short code isn’t picked up by the plugin, and I effectively just write out the short code straight to the browser.
Is there a way to get the short code evaluated properly? Or am I using the wrong function?
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)