Home › Forums › Backend Issues (wp-admin) › Queuing custom date fields
Hello there,
iam implementing an event managing system and using ACF for all the custom data inside a custom post type. The date(s) selection works like that:
Times (Repeater)
-Options(Selection: Individual Dates or Repeating Dates)
–For individual dates there is another repeater with Date and two time picker (from/to).
–For repeating dates choose a day of the week and two time picker (from/to).
Now i have different kind of date incidents on a single post.
Depending on dates i want those posts to be listed like on this example:
Monday, 12 Dezember 2016
– Event1
– Event2
Tuesday, 13 Dezember 2016
– Event1
Monday, 19 Dezember 2016
– Event2
Since event 1 has two individual dates on 12 and 13 dezember i want to see it on each of those days. Event 2 is every monday so it should be listed on every monday as well.
My question is about how to store those datas for a single post, since i don’t want to duplicate the data only for the dates. Iam thinking of generating an extra SQL-table where i store alle the (past/future) dates for an event, since i can’t see how to solve this easier.
Do you guys have any cool ideas for me?
Thanks in advance!!
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?
You must be logged in to reply to this topic.
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!
📣 “ACF Chat Fridays”
— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 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.