Function Signature:
wp_delete_post
Function Description:
Trashes or deletes a post or page.
Function Examples:
⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Delete a specific post by ID
$post_id = 25;
wp_delete_post( $post_id );
// Example 2: Delete a post and move it to trash instead of permanently deleting it
$post_id = 35;
wp_delete_post( $post_id, true );
// Example 3: Delete a post and also delete its associated meta data
$post_id = 45;
// First, delete the post meta data
delete_post_meta( $post_id, 'custom_field_key' );
// Then, delete the post itself
wp_delete_post( $post_id, true );