Query data after an Ajax insert
The function wp_insert_post() returns the post ID on success or the value 0 on error. Your PHP function should look like this : function save_enquiry_form_action() { $args = [ // Your postdata… ]; $is_post_inserted = wp_insert_post($args); if( !empty($is_post_inserted) ) { wp_send_json_success([ ‘post_id’ => $is_post_inserted, ‘post_title’ => get_the_title( $is_post_inserted ), ]); } else { wp_send_json_error(); } … Read more