has_tag()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
has_tag( string|int|array $tag = '', int|WP_Post|null $post = null ): bool
Описание
Указанные метки сверяются с term_ids, именами и слагами меток записи.
Метки, заданные целыми числами, сверяются только с term_ids меток записи.
Если метки не указаны, определяет, есть ли у записи какие-либо метки.
Подробнее об этой и подобных функциях темы см. в статье Conditional Tags в справочнике разработчика тем.
Оригинал (английский)
The given tags are checked against the post’s tags’ term_ids, names and slugs.
Tags given as integers will only be checked against the post’s tags’ term_ids.
If no tags are given, determines if post has any tags.
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Параметры
$tag
string|int|array
необязательный
= ''
$post
int|WP_Post|null
необязательный
= null
Возвращаемое значение
bool
Исходный код
wp-includes/category-template.php:1521
function has_tag( $tag = '', $post = null ) {
return has_term( $tag, 'post_tag', $post );
}
История изменений
| Версия | Описание |
|---|---|
| 2.7.0 | Can be used outside of the WordPress Loop if $post is provided. |
| 2.6.0 | Introduced. |

