関数リファレンス/wp delete attachment
This function deletes an attachment and all of its derivatives.
<?php wp_delete_attachment( $attachmentid, $force_delete ); ?>
- （integer） （必須） The ID of the attachment you would like to delete.
- 初期値： なし
- （bool） （optional） Whether to bypass trash and force deletion (added in WordPress 2.9).
- 初期値： false
Returns false on failure, post data on success. This should be checked using the identity operator ( === ) instead of the normal equality operator because of the possibility of a returned 0 or empty array:
<?php if ( false === wp_delete_attachment( $attachmentid ) ) do something; ?>
This function fires the delete_attachment action hook, passing the attachment's ID ($postid).
To delete an attachment with an ID of '76':
<?php wp_delete_attachment( 76 ); ?>
wp_delete_attachment() is located in