has_term_meta

The timeline below displays how wordpress function has_term_meta has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Gets all meta data, including meta IDs, for the given term ID.
 *
 * @since 4.9.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $term_id Term ID.
 * @return array|false Array with meta data, or false when the meta table is not installed.
 */
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);
}

WordPress Version: 5.0

/**
 * Get all meta data, including meta IDs, for the given term ID.
 *
 * @since 4.9.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $term_id Term ID.
 * @return array|false Array with meta data, or false when the meta table is not installed.
 */
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);
}

WordPress Version: 4.9

/**
 * Get all meta data, including meta IDs, for the given term ID.
 *
 * @since 4.9.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $term_id Term ID.
 * @return array|false Array with meta data, or false when the meta table is not installed.
 */
function has_term_meta($term_id)
{
    // Bail if term meta table is not installed.
    if (get_option('db_version') < 34370) {
        return false;
    }
    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);
}