Home Forums General Issues Difficulties to sort a post by DatePicker Reply To: Difficulties to sort a post by DatePicker

  • Yes I tried but it didn’t work, nothing appears.
    echo '<pre>'; print_r($posts); echo '</pre>';
    display me the array with all data and for the
    global $post;
    there’s nothing that appears.
    To be sure I show you where I put it in my code :

    <?php global $post; ?>
    <?php $posts = get_posts(array(
      'post_type'     => 'post',
      'posts_per_page'  => -1,
      'meta_key'      => 'start_date',
      'orderby'     => 'meta_value_num',
      'order'       => 'DESC'
    if( $posts ): ?> 
      <?php foreach( $posts as $post ):  
        setup_postdata( $post )
      <?php $now = time();
        $date_one_timestamp = strtotime(get_field('end_date', false, false));
        if ($now < $date_one_timestamp ) { ?>        
    <div class="event-total-page">
          <div class="category-name-event"></div>
          <div class="date-time">
            <div class="date-custom-page">   
              <?php $dateformatstring = '<p>j</p> <p>F Y</p>'; ?>
              <?php $unixtimestamp = strtotime(get_field('start_date', false, false));
              echo date_i18n($dateformatstring, $unixtimestamp); ?>
              <a href="<?php the_permalink(); ?>"><p class="view-event btn-primary">BEKIJK EVENT</p></a>

    Even if I try it in another place it doesn’t work.

    Thanks a lot John for your time.