WordPress at a glance

is_sticky() WP 1.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.

No Hooks.

Return

true/false. Whether post is sticky.

Usage

is_sticky( $post_id );
$post_id(int)
Post ID.
Default: ID of the global $post

Code of is_sticky: wp-includes/post.php VER 4.9.8

<?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;
}

Related Functions

From tag: Conditional tags (page type and request)

More from tag: Conditional tags (all)

More from category: Other

More from Template Tags: Main Functions

No comments
    Hello, !     Log In . Register