is_sticky()
Checks if the current post is attached to the top of the home page posts query. Conditional tag.
Sticky posts is a posts that should remain at the top of The Loop.
See other conditional tags.
Hooks from the function
Return
true|false
. Whether post is sticky.
Usage
<?php if( is_sticky( $post_ID ) ){ // ... } ?>
- $post_id(int)
The ID of the post you want to check whether it is attached to the main page.
If you don't specify this parameter, it will be the current post (in the loop or on the page).
Default: 0 - ID of the global $post
Examples
#1 Basic usage
if( is_sticky() ){ // this is a sticky post } if( is_sticky( 17 ) ){ // This will work if post with ID 17 is a sticky post. }
Changelog
Since 2.7.0 | Introduced. |