функция since 2.7.0

is_sticky()

Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.

Сигнатура

is_sticky( int $post_id ): bool

Описание

Прилепленные записи должны оставаться в начале Цикла. Если ID записи не указан, используется ID текущей записи в Цикле.
Подробнее об этой и похожих функциях темы см. статью Conditional Tags в Theme Developer Handbook.

Оригинал (английский)

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.

Параметры

$post_id int необязательный
ID записи. По умолчанию — ID глобального объекта $post.

Возвращаемое значение

bool

Исходный код

wp-includes/post.php:2875

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 ) ) {
		$stickies  = array_map( 'intval', $stickies );
		$is_sticky = in_array( $post_id, $stickies, true );
	} else {
		$is_sticky = false;
	}

	/**
	 * Filters whether a post is sticky.
	 *
	 * @since 5.3.0
	 *
	 * @param bool $is_sticky Whether a post is sticky.
	 * @param int  $post_id   Post ID.
	 */
	return apply_filters( 'is_sticky', $is_sticky, $post_id );
}

История изменений

ВерсияОписание
2.7.0 Introduced.

Что будем искать? Например,Продвижение

Этот сайт использует куки-файлы. Оставаясь на сайте, Вы соглашаетесь на их использование. Для получения дополнительной информации, пожалуйста, ознакомьтесь с политикой в отношении персональных данных.