Place the following function in the function.php file in the theme folder to get the categories under custom created taxonomy.
function get_the_category_by_taxonomy( $id = false, $tcat = 'category' ) {
$categories = get_the_terms( $id, $tcat );
if ( ! $categories )
$categories = array();
$categories = array_values( $categories );
foreach ( array_keys( $categories ) as $key ) {
_make_cat_compat( $categories[$key] );
}
// Filter name is plural because we return alot of categories (possibly more than #13237) not just one
return apply_filters( 'get_the_categories', $categories );
}
call the function from your template file
$terms = get_the_category_by_taxonomy('','portfollio_category');
Here the $term contains an array of categories under the taxonomy ‘portfollio_category’.
Comments