posts - Why doesn't wp_delete_post allow trashing for custom types?

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

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

Have 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

相关推荐

  • posts - Why doesn't wp_delete_post allow trashing for custom types?

    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

    10小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信