Detach an image from a page using php
There are no core (4.8.1) functions like detach_post() or wp_update_attachment() but we can use wp_update_post() to detach attachments: $result = wp_update_post( [ ‘ID’ => $attachment_id, ‘post_parent’ => 0, // detach ] ); if( is_wp_error( $result ) ) { // error } else { // success } We can also create a helper function (untested): /** … Read more