Skip to content

Instantly share code, notes, and snippets.

@petenelson
Created February 28, 2014 21:22
Show Gist options
  • Save petenelson/9280180 to your computer and use it in GitHub Desktop.
Save petenelson/9280180 to your computer and use it in GitHub Desktop.
WordPress: Advanced Custom Fields, find taxonomy term by custom value
function get_term_by_value($taxonomy, $field, $value) {
// probably a better way to do this, but this works for now
// get_field is part of Advanced Custom Fields
if (function_exists('get_field')) {
foreach (get_terms( $taxonomy ) as $term) {
$field = get_field($field, $term);
if ($value == $field)
return $field;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment