Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

wp_delete_attachment()

3 tags 1 category

wp_delete_attachment() — Trashes or deletes an attachment. When an attachment is permanently deleted, the file will also be removed. Deletion removes all post meta fields, taxonomy, comments, etc. associated with the attachment (except the main post). The attachment is moved to the Trash instead of permanently deleted unless Trash for media is disabled, item is already in the Trash, or $force_delete is true.

Inputs: $post_id (int): Attachment ID. $force_delete (bool): Optional. Whether to bypass Trash and force deletion. Default false.

Returns WP_Post|false|null: Post data on success, false or null on failure.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…