paolo_bortolotti

Loop Custom

Mar 26th, 2021 (edited)
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <main id="primary" class="site-main mt-40">
  2.    <div class="container">
  3.  
  4.  
  5.  <?php $args = array(
  6.                 'post_type' => 'prodotto',
  7.                 'posts_per_page' => -1,  //show all posts
  8.                 'tax_query' => array(
  9.                    'relation' => 'AND',
  10.                     array(
  11.                         'taxonomy' => 'categorie',
  12.                         'terms' => 'term-name',
  13.                     ),
  14.                     array(
  15.                        'taxonomy' => 'destinazione',
  16.                        'terms' => 'term-name',
  17.                    ),
  18.                 )
  19.  
  20.             );
  21.         $posts = new WP_Query($args);
  22.         if( $posts->have_posts() ): ?>
  23.         <div class="row list_destination">
  24.            <div class="col-md-12">
  25.          <h2 class="heading">
  26.             <?php
  27.             $terms = get_the_terms( $post->ID , 'categorie' );
  28.             if ( $terms != null ){
  29.             foreach( $terms as $term ) {
  30.             echo $term->name;
  31.             unset($term); } } ?>
  32.          </h2>  
  33.        
  34.            </div>
  35.    
  36.         <?php while( $posts->have_posts() ) : $posts->the_post(); ?>
  37.        <div class="col-md-4 item">
  38.   <?php $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'img-l'); ?>  
  39.         <div class="card" style="background-image: url('<?php echo $featured_img_url; ?>')">
  40.         <div class="content">
  41.             <h3>  <?php  echo get_the_title(); ?> </h3>
  42.             <p><?php the_field('tagline'); ?></p>
  43.         </div>
  44.          </div>
  45.        </div>
  46.        
  47.         <?php endwhile; ?>
  48.         </div>
  49.    
  50.         <?php endif; ?>
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. </div>
  59.  
  60.  
  61.  
  62.    </main><!-- #main -->
  63.  
Add Comment
Please, Sign In to add comment