VOOZH about

URL: https://developer.wordpress.org/reference/functions/has_term_meta/

⇱ has_term_meta() – Function | Developer.WordPress.org


Skip to content

WordPress Developer Resources

has_term_meta()

HomeReferenceFunctionshas_term_meta()

has_term_meta( int $term_id ): array|false

Gets all meta data, including meta IDs, for the given term ID.

Parameters

$term_idintrequired
Term ID.

Return

array|false Array with meta data, or false when the meta table is not installed.

Source

function has_term_meta( $term_id ) {
	$check = wp_check_term_meta_support_prefilter( null );
	if ( null !== $check ) {
		return $check;
	}

	global $wpdb;

	return $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value, meta_id, term_id FROM $wpdb->termmeta WHERE term_id = %d ORDER BY meta_key,meta_id", $term_id ), ARRAY_A );
}

View all references View on Trac View on GitHub

Related

UsesDescription
wp_check_term_meta_support_prefilter()wp-includes/taxonomy.php

Aborts calls to term meta if it is not supported.

wpdb::get_results()wp-includes/class-wpdb.php

Retrieves an entire SQL result set from the database (i.e., many rows).

wpdb::prepare()wp-includes/class-wpdb.php

Prepares a SQL query for safe execution.

Show 1 moreShow less
Used byDescription
wp_xmlrpc_server::get_term_custom_fields()wp-includes/class-wp-xmlrpc-server.php

Retrieves custom fields for a term.

Changelog

VersionDescription
4.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.