Unable to get_the_content(); of a post in WordPress via AJAX
get_the_content() must be used inside the loop, or otherwise you’ll need to use setup_postdata(); providing the post object. Try the following: function ajax_action_stuff() { $post_id = $_POST[‘post_id’]; //Query the post and set-up data $post = get_post($post_id); setup_postdata( $post ); update_post_meta($post_id, ‘post_key’, ‘meta_value’); //Return response as an array. This will give us data.title and data.content browser-side. … Read more