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

wp.media gallery collection sometimes undefined

So i finally figured it out, the gallery switches modes sometimes, even without clicking anything (not completely sure what actually happens, I have no idea about Backbone tbh.) Here is what now works for me: if(wp.media.frame.content.get(‘gallery’).collection) { wp.media.frame.content.get(‘gallery’).collection.add(formatted); } else { wp.media.frame.controller.content.get(‘gallery’).collection.add(formatted); } The else-line won’t work when initially loading of media library, so I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)