• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「関数リファレンス/wp delete attachment」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Function Reference/wp_delete_attachment 17:13, 11 December 2013‎ TheMikeD 版を流し込み。)
(相違点なし)

2015年4月14日 (火) 19:15時点における版

Description

This function deletes an attachment and all of its derivatives.

Usage

<?php wp_delete_attachment( $attachmentid, $force_delete ); ?>

Parameters

$attachmentid
integer) (必須) The ID of the attachment you would like to delete.
初期値: なし
$force_delete
bool) (optional) Whether to bypass trash and force deletion (added in WordPress 2.9).
初期値: false

Return Values

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; ?>

Hooks

This function fires the delete_attachment action hook, passing the attachment's ID ($postid).

Example

To delete an attachment with an ID of '76':

<?php wp_delete_attachment( 76 ); ?>

Source File

wp_delete_attachment() is located in wp-includes/post.php.

Related

wp_get_attachment_url()


関数リファレンステンプレートタグ目次もご覧ください。