Advertisement
Guest User

Taxonomy Images

a guest
Jun 5th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The template for displaying archive pages.
  4.  *
  5.  * @link https://codex.wordpress.org/Template_Hierarchy
  6.  *
  7.  * @package studio-pi
  8.  */
  9.  
  10. get_header(); ?>
  11.     <div class="container-fluid">
  12.         <div class="row">
  13.             <div id="primary" class="content-area">
  14.                 <main id="main" class="site-main row" role="main">
  15.                     <header class="archive-header">
  16.                         <h1 class="archive-title">Products <?php single_cat_title(); ?> </h1>
  17.                     </header>
  18.  
  19.                     <?php if ( have_posts() ) :  while ( have_posts() ) : the_post(); ?>
  20.                         <div class="col-sm-12 col-md-3">                   
  21.                             <?php  
  22.                                 $terms = get_the_terms( get_the_ID(), 'department' );
  23.                                 foreach ( $terms as $term ) {
  24.                                     $file = get_term_meta( $term->term_id, '_cmb2_term_dept_img', true );
  25.                                    
  26.                                         echo '<a href="/department/' . $term->slug . '">' . $term->name . '</a>';
  27.                                         echo '<div style="border:1px solid blue;">';
  28.                                             echo '<img src="';
  29.                                                 echo esc_attr($file);
  30.                                             echo '" class="dept-img">';
  31.                                         echo '</div>';
  32.                                 }
  33.                                     echo "</div>";// closes .col-sm-12 and .col-md-3 div
  34.                                    
  35.                             ?>
  36.                     <?php endwhile; else : ?>
  37.                             <p><?php _e( 'Sorry, no posts in this department.' ); ?></p>
  38.                     <?php endif; ?>
  39.  
  40.                 </main><!-- #main -->
  41.             </div><!-- #primary -->
  42.         </div>
  43.     </div>
  44. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement