wp_delete_post 删除文章或页面

Posted in:
Update time:2020-10-28

函数描述

永久删除回收站中的文章、附件或页面。当一篇文章被删除时,关联到这篇文章的所有内容将同时被删除,包括评论、自定义字段和文章到分类项目之前的关联。

Usage

<?php wp_delete_post( $postid, $force_delete ); ?>

parameters

parametersdata typeRequired or notdescriptivedefault value
$postidinteger (math.)clogged文章ID0
$force_delete布尔值clogged是否跳过回收站强制删除false

return value

(mixed) 文章对象(如果删除或移到回收站成功),失败时返回 false,如果文章被移动到了回收站,$post 对象为文章的新状态,如果被永久删除,$post 为文章删除之前的状态。

usage example

删除文章

删除默认的,ID为1,标题为 “Hello World” 的WordPress文章。

<?php wp_delete_post(1); ?>

We offer WordPress Themes and Plugins Custom Development Services

This site has long undertaken WordPress themes, plugins, WooCommerce-based store mall development business. We have 10 years of experience in WordPress development, if you want to Developing Websites with WordPress, please contact WeChat: iwillhappy1314 or email: amos@wpcio.com for inquiries.

发表回复

Your email address will not be published. 必填项已用 * 标注

*