delete post also attachments
Maybe this works function remove_post() { if(isset($_POST[‘post_id’]) && is_numeric($_POST[‘post_id’])) { $post = get_post($_POST[‘post_id’]); if(get_current_user_id() == $post->post_author) { $args = array( ‘post_parent’ => $_POST[‘post_id’] ); $post_attachments = get_children($args); if($post_attachments) { foreach ($post_attachments as $attachment) { wp_delete_attachment($attachment->ID, true); } } wp_delete_post($_POST[‘post_id’], true); } } exit; } The code added function get_attachment_id_from_src ($image_src) { global $wpdb; $query = … Read more