Wordpress: shortcode doesn't work when getting post content using function get_post_field()
This will work:
echo do_shortcode(get_post_field('post_content', $postid));
Edit
If you want to forcefully output shortcode within Ajax, please see running shortcode inside AJAX request
You need to filter your content before displaying it, so try the following code:
echo apply_filters( 'the_content', get_post_field('post_content', $postid) );
Update:
You can't output shortcodes using ajax calls hooked into wp_ajax
.
WP Ajax
runs both public as well as closed calls via admin.php
. This means that you don't have access to the whole wp environment, such as do_shortcode()
, which is inside /wp-includes/shortcodes.php
.