I am trying to delete a post with its all attachments. This is the function that i came up with right now;
function remove_post(){
if(isset($_POST['post_id']) && is_numeric($_POST['post_id'])){
$post = get_post($_POST['post_id']);
if(get_current_user_id() == $post->post_author){ echo 'ee';
wp_delete_post($_POST['post_id']);
}
}
exit;
}
This deletes the post but not the attachments link to that post also its not hard deleting, the post remains in the trash. So what do you think? Thanks.
Maybe this works
The code added
See the codex for the correct use of wp_delete_post, use
to bypass the trash