Uma área de pesquisa sobre o WordPress para devs e autores do tema



is_sticky ›

Desde2.7.0
Obsoleton/a
is_sticky ( $post_id = 0 )
Parâmetros:
  • (int) $post_id Optional. Post ID. Default is ID of the global $post.
    Required: No
    Padrão:
Retorna:
  • (bool) Whether post is sticky.
Definido em:
Codex:

Determines whether a 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.

For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook.



Fonte

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