<?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 ; }; ?>
get_term_meta: Source code
source code of the function in the file functions.php of the wp-content/plugins/zyx-term-meta/includes folder ZYX Term Meta get_term_meta
By the Web Warlock, Sunday, 23/May/2010 0:41
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL
Leave a comment
208 queries. 0.501 seconds. Powered by WordPress
Code is magic