Fix error on get itemMetadada value for field type Category

This commit is contained in:
Eduardo humberto 2018-03-09 12:33:42 -03:00
parent 3fae4a1480
commit efa0aa3c04
1 changed files with 13 additions and 2 deletions

View File

@ -123,8 +123,19 @@ class Item_Metadata extends Repository {
return $item->$get_method();
} elseif ($field_type->get_primitive_type() == 'term') {
$terms = wp_get_object_terms($item_metadata->get_item()->get_id(), $field_type->get_option('taxonomy_id'));
if( is_numeric( $field_type->get_option('taxonomy_id') ) ){
$taxonomy = new Entities\Taxonomy( $field_type->get_option('taxonomy_id') );
if( $taxonomy ){
$taxonomy_slug = $taxonomy->get_db_identifier();
} else {
return [];
}
} else {
return [];
}
$terms = wp_get_object_terms($item_metadata->get_item()->get_id(), $taxonomy_slug );
if ($unique)
$terms = reset($terms);