Wordpress: custom post type delete post permanently

admin

Administrator
Staff member
So I want my posts in my custom post type deleted permanently instead of moving to trash first.
so I found this code online that is supposed to do the trick.
But I'm not able to get it to work somehow.

The code that I have is as follows.

Code:
function directory_skip_trash($post_id) {
    if (get_post_type($post_id) == 'directory') {
        // Force delete
        wp_delete_post( $post_id, true );
    }
}
add_action('wp_trash_post', 'directory_skip_trash');

<hr>

The rest of the code of my custom post type itself u can find in <a href="https://stackoverflow.com/questions...ke-unique-field-with-acf-and-custom-post-type">this post</a> that I've made earlier.

I'm probably missing out on something pretty simple.

<strong>UPDATE</strong>

so now it got it to kinda work.
It does actually delete the post but I get this error.
<a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>
after the error, if I return to the post page the post is gone and not in the trash
anyone that might have a solution for it to just remove and not give this message?