関数リファレンス/wp delete post
Removes a post, attachment, or page.
When the post and page goes, everything that is tied to it is deleted also. This includes comments, post meta fields, and terms associated with the post.
%%%<?php wp_delete_post( $postid, $force_delete = false ) ?>%%%
- （integer） （optional） Post ID.
- 初期値： 0
- （bool） （optional） Whether to bypass trash and force deletion (added in WordPress 2.9).
- 初期値： false
- False on failure.
Deleting WP default post "Hello World" which ID is '1'.
<?php wp_delete_post(1); ?>
- Uses: do_action() on 'delete_post' before deletion unless post type is 'attachment'.
- Uses: do_action() on 'deleted_post' after deletion unless post type is 'attachment'.
- Uses: wp_delete_attachment() if post type is 'attachment'.
- Uses global: (object) $wpdb
- Uses global: (object) $wp_rewrite
wp_delete_post() is located in wp-includes/post.php.