贴一个帖子。

原型

stick_post( int $post_id )

描述

粘性帖子应显示在首页的顶部。

参数

$post_id (int) (Required) 帖子ID。

源文件

路径:wp-includes/post.php

<?php
...
function stick_post( $post_id ) {
	$stickies = get_option('sticky_posts');
	if ( !is_array($stickies) )
		$stickies = array($post_id);
	if ( ! in_array($post_id, $stickies) )
		$stickies[] = $post_id;
	$updated = update_option( 'sticky_posts', $stickies );
	if ( $updated ) {
		/**
		 * Fires once a post has been added to the sticky list.
		 *
		 * @since 4.6.0
		 *
		 * @param int $post_id ID of the post that was stuck.
		 */
		do_action( 'post_stuck', $post_id );
	}
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/stick_post/