Support

Account

Home Forums General Issues Using ACF date to sort custom post types not sorting correctly Reply To: Using ACF date to sort custom post types not sorting correctly

  • This is my field (sorry in Dutch):

    This is the loop

    
    <?php $args = array(
    	'post_type' => 'foto_archief',
    	'orderby' => 'meta_value_num',
    	'meta_key'  => 'date',
    	'order' => 'ASC',
    	'posts_per_page' => -1
    );
    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) :
    	while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    		<h3><?php the_title(); ?></h3>
    		<p><?php echo get_field('date'); ?></p>
    
    <?php endwhile; endif; wp_reset_postdata(); ?>
    

    And this is what the list looks like

    1. 26 januari, 2012
    2. 27 januari, 2012
    3. 24 januari, 2011
    4. 24 januari, 2011
    5. 24 januari, 2011
    6. 26 januari, 2012
    7. 15 december, 2013
    8. 22 december, 2016
    9. 27 september, 2016