WordPress at Your Fingertips

has_term() WP 1.0

Check if the current post has any of given terms.

The given terms are checked against the post's terms' term_ids, names and slugs. Terms given as integers will only be checked against the post's terms' term_ids.

If no terms are given, determines if post has any terms.

1 time — 0.003337 sec (very slow) | 50000 times — 0.82 sec (very fast) | PHP 7.1.5, WP 4.8.1

No Hooks.


true|false. True if the current post has any of the given terms (or any term, if no term specified). False otherwise.


has_term( $term, $taxonomy, $post );
The term name/term_id/slug, or an array of them to check for.
Default: ''
Taxonomy name.
Default: ''
Post to check instead of the current post.
Default: null


Since 3.1.0 Introduced.

Code of has_term() WP 5.8.1

function has_term( $term = '', $taxonomy = '', $post = null ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;

	$r = is_object_in_term( $post->ID, $taxonomy, $term );
	if ( is_wp_error( $r ) ) {
		return false;

	return $r;

Term (taxonomies terms)

Conditional tags (all)

For posts

No comments
    Log In