is_sticky( int $post_id )
Determines whether a post is sticky.
Description 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.
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Parameters Parameters
- $post_id
-
(int) (Optional) Post ID. Default is ID of the global $post.
Return Return
(bool) Whether post is sticky.
Source Source
File: wp-includes/post.php
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 | 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; } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
is_sticky();
// When any Sticky Post page is being displayed.
is_sticky(
'17'
);
// When Sticky Post 17 (ID) is being displayed.