Home › Forums › Backend Issues (wp-admin) › Queuing custom date fields › Reply To: Queuing custom date fields
From https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ 4. Sub custom field values i derived the following:
function my_posts_groupby() {
return '';
}
add_filter( 'posts_groupby', 'my_posts_groupby' );
function my_posts_where($where)
{
$where = str_replace("meta_key = 'daten_%_datum", "meta_key LIKE 'daten_%_datum", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
// find todays date
$date = date('Ymd');
// args
$args = array(
'numberposts' => -1,
'post_type' => 'angebotecpt',
'meta_query' => array(
array(
'key' => 'daten_%_datum',
'compare' => '!=',
'value' => $date,
))
);
$query = new WP_Query($args);
Since i overwrite the my_posts_groupby filter i receive ALL posts (multiple occurence), which are NOT today for now. Thats pretty much what i wanted. But what iam still missing is how i can order those posts in my query for all those custom date fields.
Wanted result:
query order:
Event1:Yesterday
Event2:Tommorow
Event1:Day after tommorrow
and so on
I think i can use the orderby function for that. Any ideas?
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
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.