vic4884
10/28/2018 - 3:17 PM

вывод тегов для постов кастомных типов записей

вывод тегов для постов кастомных типов записей

<?php 
/*

   проверка страницы поста типа записи
   выводит теги в соответствии с типом записей 

*/
?>
<?php 

 $url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
 
 if(strpos($url,'yellow')){
     $terms = get_the_terms( $post->ID, 'tag-yellow');
       foreach( $terms as $term ){
         echo '<a class="' . $term->description . '" href="' . get_term_link( $term ) . '">' . $term->name .  '</a>' . ' ';
    }   
 }
 else if(strpos($url,'orange')){
     
     $terms = get_the_terms( $post->ID, 'tag-orange');
        foreach( $terms as $term ){
          echo '<a class="' . $term->description . '" href="' . get_term_link( $term ) . '">' . $term->name .  '</a>' . ' ';
         }   
 }
 else if(strpos($url,'violet')){
     $terms = get_the_terms( $post->ID, 'tag-violet');
       foreach( $terms as $term ){
        echo '<a class="' . $term->description . '" href="' . get_term_link( $term ) . '">' . $term->name .  '</a>' . ' ';
        }  
 }
 
         ?>