jcadima
3/8/2017 - 4:10 PM

get category by taxonomy

get category by taxonomy



<?php
global $post;

$post->classes = array();
// item classes filter
$filter_tags = get_the_terms( $post->ID, 'oxy_portfolio_categories' );
if( $filter_tags && ! is_wp_error( $filter_tags ) ) :
    foreach( $filter_tags as $tag ):
        $post->classes[] = 'filter-' . $tag->slug;
    endforeach;
endif;
?>

<div class="masonry-afc">
 <p class="lorafont">
 <?php 
/*   
Array
(
    [0] => filter-fish
) 
*/    
   //echo $post->classes[0] . "<br>";
   $catname = explode('-', $post->classes[0] ) ; // after filter get category name
   //print_r( $catname)  ;  

   echo strtoupper($catname[1]) . "<br>"; // get fish
   the_title(); 
?>				
  </p>

</div>