wp_delete_post function allows us to permanently delete posts, pages, attachments. When a post is deleted, all the associated content will also be deleted, this includes the comments, custom fields, and category entries.
<?php wp_delete_post( $postid, $force_delete ); ?>
|$force_delete||boolean||skip recycle bin and delete permanently||false||no|
(mixed) The post object (if deleted or moved to the recycle bin is successful), it returns false when it fails. If the post is moved to the recycle bin, the $post object is the new state of the post. If it is permanently deleted, $post is the one before the post is deleted.
Delete the default WordPress post with ID 1 and title “Hello World”:
<?php wp_delete_post(1); ?>