wp_update_post()通过代码更新文章的内容和信息

目录

描述

译文

该函数更新数据库中的文章。如希望函数正常运行,需传递将被更新的文章编号。

原文

This function updates posts (and pages) in the database. To work as expected, it is necessary to pass the ID of the post to be updated.

Note that when the post is "updated", the existing Post record is duplicated for audit/revision purposes. The primary record is then updated with the new values. Category associations, custom fields, post meta, and other related entries continue to be linked to the primary Post record.

wp_update_post() 描述

用法

 <?php wp_update_post$post$wp_error ); ?> 

wp_update_post() 用法

参数

$post

(array/object) (可选) An array or object representing the elements that make up a post. There is a one-to-one relationship between these elements and the names of columns in the wp_posts table in the database. Filling out the ID field is not strictly necessary but without it there is little point to using the function.

默认值: An empty array

$wp_error

(Boolean) (可选) A Boolean that can be passed to control what is returned on failure. The default setting (false) will return a 0 if the post fails to update. However, if this is set to true, it will return with a WP_Error object.

默认值: false

wp_update_post() 参数

历史

  • 添加于 版本: 1.0.0

wp_update_post() 历史

源文件

wp_update_post() 函数的代码位于 wp-includes/post.php.

wp_update_post() 源文件

相关