is_sticky()
最后更新于:2021-11-27 11:18:28
is_sticky( int$post_id)Determines whether a post is sticky.
参数
- $post_id
-
(int) (Optional) Post ID. Default is ID of the global $post.
响应
(bool) Whether post is sticky.
源文件
文件: gc-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 );
}