admin管理员组文章数量:1415421
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.
本文标签: postsWhy doesn39t wpdeletepost allow trashing for custom types
版权声明:本文标题:posts - Why doesn't wp_delete_post allow trashing for custom types? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745223294a2648492.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论