Support

Account

Home Forums Add-ons Repeater Field Query repeater sub-field date Reply To: Query repeater sub-field date

  • I found the answer, if it can help !

    <?php 
    date_default_timezone_set('Europe/Paris'); 
    $date_1 = date('Ymd', strtotime("now")); 
    $date_2 = date('Ymd', strtotime("+12 months"));
    ?>
    
    <?php
    function my_posts_where( $where ) {
    $where = str_replace("meta_key = 'evenement_%", "meta_key LIKE 'evenement_%", $where);
    return $where;
    }
    add_filter('posts_where', 'my_posts_where');
    ?>
    
    <?php 
    $upcoming_args = array(
    'category_name' => '2017',
    'post_type' => 'spectacles',
    'posts_per_page' => 100,
    'meta_key' => 'evenement_%_date_fin_evenement',
    'meta_compare' => 'between',
    'meta_type' => 'numeric',
    'meta_value' => array($date_1, $date_2),
    'orderby' => 'meta_value_num',
    'order' => 'ASC'); 
    ?>
    <?php $upcoming_query = new WP_Query( $upcoming_args ); ?>
    <?php if ( $upcoming_query->have_posts() ) : ?>					
    <?php while ( $upcoming_query->have_posts() ) : $upcoming_query->the_post(); ?>