get_term_meta

Description

located in the file / of the plugin . Reads the fields and of the table. Uses the functions , , and , and the methods and and the property of the global object .

Returns the term metadata for the specified term_id and key.

Synopsis

<?php get_term_meta( $term_id , $key , $single = false , $use_cache = true , $single_id = 0 );

Source

<?php function get_term_meta( $term_id , $key , $single = false , $use_cache = true , $single_id = 0 ){
	global $wpdb ;
	$table = $wpdb->prefix . "termmeta" ;
	if( $use_cache ){
		$results = get_term_meta_from_cache( $term_id, $key ) ;
	} else {
		$query = $wpdb->prepare( "SELECT meta_value FROM $table WHERE term_id=%d AND meta_key=%s",
			$term_id, (string)$key ) ;
		$results = $wpdb->get_col( $query ) ;
	};
	if ( $single ) {
		list( $max_id , $min_id ) = array( max( 0 , count( $results ) - 1 ) , 0 );
		if( ( 'rand' == mb_strtolower( $single_id ) ) ){
			$single_id = wp_rand( $min_id , $max_id );
		} else {
			$single_id = min( $single_id , $max_id );
		};
		$results = isset( $results[$single_id] ) ? maybe_unserialize( $results[$single_id] ) : NULL ;
	} else {
		$results = array_map( 'maybe_unserialize' , $results );
	};
	$results = apply_filters( 'get_term_meta' , $results ,  $term_id , $key , $single , $use_cache , $single_id ) ;
	return $results ;
}; ?>