Home › Forums › General Issues › Difficulties to sort a post by DatePicker › Reply To: Difficulties to sort a post by DatePicker
Hello John !
I finally find a solution and I post it here if it can help someone :
<?php $custom_query_args = array('numberposts' => -1,
'posts_per_page' => 10,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'type',
'value' => 'evenement',
'compare' => '='
)
),
'meta_key' => 'start_date',
'orderby' => 'meta_value',
'order' => 'ASC',
);
// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );
// Output custom query loop
if ( $custom_query->have_posts() ) :
while ( $custom_query->have_posts() ) :
$custom_query->the_post(); ?>
// Here is your code
//Close
<?php
endwhile;
endif;
wp_reset_postdata(); ?>
I use WP_Query and resolve my problem of the double meta_key by using the meta_query to display both my posts who are type “event” and to order event by my “start_date” field.
Thank you !
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.