Advertisement
wardhanarizaldi

WP list taxonomy terms on archive page

Feb 19th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1.         <?php
  2.         // Get the taxonomy's terms
  3.         $terms = get_terms(
  4.             array(
  5.                 'taxonomy'   => 'brand',
  6.                 'hide_empty' => false,
  7.             )
  8.         );
  9.        
  10.         // Check if any term exists
  11.         if ( ! empty( $terms ) && is_array( $terms ) ) {
  12.             // Run a loop and print them all
  13.             foreach ( $terms as $term ) {
  14.         ?>
  15.            
  16.             <div class="uk-card uk-card-primary uk-card-body">
  17.                 <a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
  18.                     <?php echo $term->name; ?>
  19.                 </a>
  20.                 <div>
  21.                 <img src="<?php the_field('logo');?>" alt="">
  22.                 </div>
  23.             </div>
  24.  
  25.         <?php
  26.             }
  27.         }            
  28.            
  29.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement