返回介绍

wp_publish_post()

发布于 2017-09-11 12:38:08 字数 2311 浏览 905 评论 0 收藏 0

wp_publish_post( int|WP_Post $post )

Publish a post by transitioning the post status.


description


参数

$post

(int|WP_Post) (Required) Post ID or post object.


源代码

File: wp-includes/post.php

function wp_publish_post( $post ) {
	global $wpdb;

	if ( ! $post = get_post( $post ) )
		return;

	if ( 'publish' == $post->post_status )
		return;

	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) );

	clean_post_cache( $post->ID );

	$old_status = $post->post_status;
	$post->post_status = 'publish';
	wp_transition_post_status( 'publish', $old_status, $post );

	/** This action is documented in wp-includes/post.php */
	do_action( 'edit_post', $post->ID, $post );

	/** This action is documented in wp-includes/post.php */
	do_action( "save_post_{$post->post_type}", $post->ID, $post, true );

	/** This action is documented in wp-includes/post.php */
	do_action( 'save_post', $post->ID, $post, true );

	/** This action is documented in wp-includes/post.php */
	do_action( 'wp_insert_post', $post->ID, $post, true );
}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/plugin.php: do_action()
  • wp-includes/post.php: clean_post_cache()
  • wp-includes/post.php: wp_transition_post_status()
  • wp-includes/post.php: edit_post
  • wp-includes/post.php: save_post_{$post->post_type}
  • wp-includes/post.php: save_post
  • wp-includes/post.php: wp_insert_post
  • wp-includes/post.php: get_post()
  • wp-includes/wp-db.php: wpdb::update()
  • Show 4 more uses Hide more uses

Used By

  • wp-includes/post.php: check_and_publish_future_post()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文