Advertisement
HM-Design

loop ag3

Nov 14th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.02 KB | None | 0 0
  1. <?php
  2.     $meta_query = array(
  3.         array(
  4.             'key' => 'date_de_representation_debut',
  5.             'value' => date('d/m/Y'),
  6.             'type' => 'DATE',
  7.             'compare' => '>=',
  8.         ),
  9.         array(
  10.         'key'     => 'statut',
  11.         'value'   => 'on',
  12.         'compare' => 'LIKE',
  13.     ),
  14.     );
  15.     $args = array(
  16.         'post_type' => 'spectacle',
  17.         'orderby' => 'meta_value_num',
  18.         'order' => 'ASC',
  19.         'posts_per_page' => '3',
  20.         'meta_query' => $meta_query
  21.     );
  22.  
  23.     $loop = new WP_Query( $args );
  24.     if( $loop->have_posts()): while( $loop->have_posts() ): $loop->the_post(); ?>
  25.     <?php // var_dump( date('d/m/Y') < get_field('date_de_representation_fin')); ?>
  26.     <!-- article -->
  27.     <article id="post-<?php the_ID(); ?>" class="row-fluid clearfix">
  28.  
  29.         <!-- post details -->
  30.         <span class="date">
  31.             <?php
  32.                 is_null( the_field('date_de_representation_unique') ) ? 'Du ' . the_field('date_de_representation_debut') . ' au ' . the_field('date_de_representation_fin') : the_field('date_de_representation_unique') . '<span class="badge badge-light">Date unique</span>';
  33.     ?>
  34.         </span><br>
  35.         <!-- /post details -->
  36.  
  37.         <!-- post thumbnail -->
  38.         <div class="col-md-2 post-thumbnail">
  39.             <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
  40.             <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  41.                 <?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?>
  42.             </a>
  43.             <?php else: ?>
  44.             Agenda
  45.             <?php endif; ?>
  46.         </div>
  47.         <!-- /post thumbnail -->
  48.  
  49.         <!-- post title -->
  50.         <div class="col-md-6">
  51.             <h2>
  52.                 <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
  53.             </h2>
  54.             <a href="<?php the_permalink(); ?>" class="more-link">En savoir +</a>
  55.         </div>
  56.         <!-- /post title -->
  57.  
  58.  
  59.     </article>
  60.     <!-- /article -->
  61.  
  62.     <?php endwhile; ?>
  63.  
  64.     <?php else: ?>
  65.  
  66.     <!-- article -->
  67.     <article>
  68.         <h2><?php _e( 'Désolé, rien à afficher.', 'html5blank' ); ?></h2>
  69.     </article>
  70.     <!-- /article -->
  71.  
  72.  
  73.     <?php endif; wp_reset_postdata(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement