wp_after_insert_post

函数
wp_after_insert_post ( $post, $update, $post_before )
参数
  • (int|WP_Post) $post The post ID or object that has been saved.
    Required:
  • (bool) $update Whether this is an existing post being updated.
    Required:
  • (null|WP_Post) $post_before Null for new posts, the WP_Post object prior to the update for updated posts.
    Required:
定义位置
相关方法
wp_insert_postwp_insert_sitewp_get_single_postwp_trash_postwp_filter_kses
引入
5.6.0
弃用
-

wp_after_insert_post。这个钩子在一个文章被插入到数据库后启动。它传递文章的ID作为参数。

在一个文章、其条款和元数据被保存后触发行动。

function wp_after_insert_post( $post, $update, $post_before ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return;
	}

	$post_id = $post->ID;

	/**
	 * Fires once a post, its terms and meta data has been saved.
	 *
	 * @since 5.6.0
	 *
	 * @param int          $post_id     Post ID.
	 * @param WP_Post      $post        Post object.
	 * @param bool         $update      Whether this is an existing post being updated.
	 * @param null|WP_Post $post_before Null for new posts, the WP_Post object prior
	 *                                  to the update for updated posts.
	 */
	do_action( 'wp_after_insert_post', $post_id, $post, $update, $post_before );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-28 22:09:22

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: