Skip to content

Instantly share code, notes, and snippets.

@geilt
Created May 9, 2013 08:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geilt/5546181 to your computer and use it in GitHub Desktop.
Save geilt/5546181 to your computer and use it in GitHub Desktop.
get_term_meta
<?php
if(!function_exists('get_term_meta')):
function get_term_meta($term, $taxonomy, $key, $single = false ){
if(!$taxonomy && !$term):
return false;
endif;
if(!is_numeric($term)):
$term = get_term_by('slug', $term, $taxonomy);
$term = $term->term_id;
endif;
$term = get_option('taxonomy_' . $term);
if($key):
if(!empty($term[$key])) return $term[$key]; else return '';
endif;
return $term;
}
endif;
if(!function_exists('the_term_meta')):
function the_term_meta($term, $taxonomy, $key, $single = false ){
if(!$term && !$taxonomy && !$value):
return false;
endif;
echo get_term_meta($term, $taxonomy, $key, true);
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment