When you're trying to wp_delete_post
a custom post type, it deletes it fully instead of moving it to trash as it is the normal behavior.
This happens because "force delete" is, by default false and it will only trash the post if it's of post / page type:
.9/src/wp-includes/post.php#L2467
Why is this happening and what are the dangers of re-writing this to handle every post type?
When you're trying to wp_delete_post
a custom post type, it deletes it fully instead of moving it to trash as it is the normal behavior.
This happens because "force delete" is, by default false and it will only trash the post if it's of post / page type:
https://core.trac.wordpress/browser/tags/4.9/src/wp-includes/post.php#L2467
Why is this happening and what are the dangers of re-writing this to handle every post type?
Share Improve this question asked Aug 22, 2019 at 17:49 coolpastacoolpasta 9691 gold badge9 silver badges24 bronze badges1 Answer
Reset to default 0Have you tried wp_trash_post?
This seems like the perfect fit for your purpose. It will only permanently delete posts if you have your trash disabled, or added define('EMPTY_TRASH_DAYS', 0);
to your wp-config.php file.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745223294a4617346.html
评论列表(0条)