函数原型
is_sticky( int $post_id ): bool
函数描述
Determines whether a post is sticky.
是否弃用
未弃用
函数参数
-
$post_id
int
Optional - Post ID. Default is the ID of the global
$post.
函数返回值
bool Whether post is sticky.
函数位置
File: wp-includes/post.php.
函数源码
function is_sticky( $post_id = 0 ) {
$post_id = absint( $post_id );
if ( ! $post_id ) {
$post_id = get_the_ID();
}
$stickies = get_option( 'sticky_posts' );
if ( is_array( $stickies ) ) {
$stickies = array_map( 'intval', $stickies );
$is_sticky = in_array( $post_id, $stickies, true );
} else {
$is_sticky = false;
}
/**
* Filters whether a post is sticky.
*
* @since 5.3.0
*
* @param bool $is_sticky Whether a post is sticky.
* @param int $post_id Post ID.
*/
return apply_filters( 'is_sticky', $is_sticky, $post_id );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |

