Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




is_sticky [ WordPress Function ]

is_sticky ( $post_id = 0 )
Parameters:
  • (int) $post_id Optional. Post ID.
Returns:
  • (bool) Whether post is sticky.
Defined at:



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.

Source


<?php
function is_sticky$post_id ) {
    
$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;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics