is_sticky( int $post_id )

Check if post is sticky.


Description

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.


Parameters

$post_id

(int) (Optional) Post ID. Default is ID of the global $post.


Return

(bool) Whether post is sticky.


Source

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 ) )
		return false;

	if ( in_array( $post_id, $stickies ) )
		return true;

	return false;
}


Changelog

Changelog
Version Description
WP-2.7.0 Introduced.