wp_delete_attachment( int $post_id, bool $force_delete = false )

Trash or delete an attachment.


25 related functions found for: wp_delete_attachment

Top ↑

Related terms found for this post

TaxonomyTerms
wp-parser-related-wordsattach, attachment, attachments, delet, delete, post-php, post-typ, post-type, wp-delete, wp-includes
wp-parser-packagePost, WordPress
wp-parser-source-filewp-includes/post.php

Top ↑

Terms Used Terms Used

Terms used in the related posts query

  • attach
  • attachment
  • attachments
  • delet
  • delete
  • Post
  • post-php
  • post-typ
  • post-type
  • wp-delete
  • wp-includes
  • wp-includes/post.php
  • post

Top ↑

Description Description

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.


Top ↑

Parameters Parameters

$post_id

(int) (Required) Attachment ID.

$force_delete

(bool) (Optional) Whether to bypass trash and force deletion.

Default value: false


Top ↑

Return Return

(mixed) False on failure. Post data on success.


Top ↑

Source Source

File: wp-includes/post.php


			

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.