Wordpress: Permanently deleting custom post type post. remove the: “1 post moved to the Trash. Undo” message

点点圈 提交于 2020-03-23 02:02:04

问题


Sorry if there is already an answer to this but I couldn't find it.

So I have this script that permanently deletes a post from a custom post type. It does permanently delete the post. but after it's deleted I get this message:

But I want this message gone because even if u the press undo button it just says:

the code for deleting the posts is:

function members_skip_trash($post_id) {
    if (get_post_type($post_id) == 'members') { 
        // Force delete
        wp_delete_post( $post_id, true );
    }
}
add_action('trashed_post', 'members_skip_trash');

So how do I get rid of the 1 post moved to the trash message?


回答1:


A quick and dirty way to do it would be to find this file:

/wp-admin/edit.php

And comment out the following line:

echo '<div id="message" class="updated notice is-dismissible"><p>' . join( ' ', $messages ) . '</p></div>';

Of course that will get rid of all your 'moved to Trash' messages. So you'll probably want to keep it in there, but check for your custom post type first.

Or better yet, figure out how to override this from your functions.php file so the next WP update doesn't kill it.



来源:https://stackoverflow.com/questions/60447483/wordpress-permanently-deleting-custom-post-type-post-remove-the-1-post-moved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!