is_sticky

The timeline below displays how wordpress function is_sticky has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.9

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`.
 * @return bool Whether post is sticky.
 */
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);
}

WordPress Version: 5.5

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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);
}

WordPress Version: 5.3

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
function is_sticky($post_id = 0)
{
    $post_id = absint($post_id);
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    $stickies = get_option('sticky_posts');
    $is_sticky = is_array($stickies) && in_array($post_id, $stickies);
    /**
     * 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);
}

WordPress Version: 5.1

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: 0.3

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 * 
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
 * Conditional Tags} article in the Theme Developer Handbook.
 * 
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: .20

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: 0.2

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 * 
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
 * Conditional Tags} article in the Theme Developer Handbook.
 * 
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: .18

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: 5.0

/**
 * Determines whether a post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 * 
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
 * Conditional Tags} article in the Theme Developer Handbook.
 * 
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: 4.0

/**
 * Check if post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Check if post is sticky.
 *
 * Sticky posts should remain at the top of The Loop. If the post ID is not
 * given, then The Loop ID for the current post will be used.
 *
 * @since 2.7.0
 *
 * @param int $post_id Optional. Post ID.
 * @return bool Whether post is sticky.
 */
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)) {
        return false;
    }
    if (in_array($post_id, $stickies)) {
        return true;
    }
    return false;
}