I think you would have to make the country drop down then various region drop downs that are conditional to a selection in the country drop down.
Hi Edd – when I tried this query out it displayed zero events. I even changed $right_now to h:mm TT as its set in the Time Picker. Or is my problem that I’m using the time picker?
My time picker field is set to event_start_time
Edd – in your application have you looked into having the events fall off by time of the current date?
Gotcha! By the way, ACF 4 (free) has a Date/Time Picker plugin add-on that I was able to install and sort out the time.
ACF Pro has it’s own forum.
Edd – This worked! Thank you! Now I just have to sort out how to order am from pm without using military time or if using military time how to display 1600 as 4pm.
I wasn’t aware they had multiple wordpress plugins.
Edd – This query shows only upcoming events while not displaying past events and then sorts by date and if on the same date then by start time?
But how far out is that? I’m on the most recent version and it’s only 4.4.7. I need a solution now, not 6 months from now.
Did you ever figure this out? I can get the multi query to work but I cannot seem to get the meta values in a drown down to query it.
Still no response here or via email…
I know SQL uses date() but I thought WordPress uses the_date and current_time. In either event for my installation current_time worked vs date.
But yeah… that’s quite a process. So do you have to change those date ranges every month? There has to be an easier way to get those date ranges than a manual range like that.
OMG what a pain. I got it!
so use their tutorial on comparing dates but instead of date(‘Ymd’) use current_time
$today = current_time('Ymd');
$args = array (
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'start_date',
'compare' => '<=',
'value' => $today,
),
array(
'key' => 'end_date',
'compare' => '>=',
'value' => $today,
)
),
);
I removed all that stuff in the functions.php and just did
$event1 = current_time(‘Ymd’) then for my array I used a key of my end date field compare to greater than $event1 (aka current date in Ymd).
What I did was convert the stored data for my end date to unix timecode in my functions.php file like so
function custom_unixtimesamp ( $post_id ) {
if ( get_post_type( $post_id ) == 'events' ) {
$enddate = get_post_meta($post_id, 'event_date_ends', true);
if($enddate) {
$dateparts = explode('/', $enddate);
$newdate1 = strtotime(date('d.m.Y H:i:s', strtotime($dateparts[1].'/'.$dateparts[0].'/'.$dateparts[2])));
update_post_meta($post_id, 'unixstartdate', $newdate1 );
}
}
}
add_action( 'save_post', 'custom_unixtimesamp', 100, 2);
then queried as such
$today = time();
$args = array(
'post_type' => 'events',
'post_status' => 'publish',
'posts_per_page' => '10',
'meta_query' => array(
array(
'key' => 'unixstartdate',
'compare' => '>=',
'value' => $today,
)
),
'meta_key' => 'event_date_begins',
'orderby' => 'meta_value',
'order' => 'ASC',
However what I thought fixed the issue actually didn’t. While you’re trying for a monthly date range I’m looking for just upcoming events. I had 2 events created. One future date and one past date. Using this code the past date event went away so I thought problem solved until I went in to enter more future dates which did not show up. I removed the functions.php code and the result was the same so it must not be converting the time properly. I too am using yymmdd but sql, to my understanding need yy-mm-dd (2014-06-19).
Are you using WordPress? If so how did you get it to understand the year without the hyphens?
For your array couldn’t you just query event_start_date $current_month?
'key' => 'event_start_date',
'value' => $current_month
then array
'key' => 'event_end_date',
'value' => $current_month
using a compare of AND
That should return anything with a start date for the month of current and end date for the current month.
I was able to solve my problem by converting YYMMDD (Ymd) to unix timestamp in my functions.php then you can query array for a date range.
Were you able to change from the YYYYMMDD saved format to YYYY-MM-DD or is that why you added $current_month, $current_day, $current_year?
Have you come up with a solution yet. I’m working on the exact same issue with no luck as of yet.
Thank you much!
I disabled all plugins, which didn’t work. Deleted the plugins folder (after backing up of course), which didn’t work. Finally what did work was a fresh WordPress install then turning everything back on. There it was again.
Strange. Not sure if it was something up with the 3.9.1 update or what but it’s back.
deactivated, reactivated, still missing! Please update or I will have to find an alternative solution and be set back 2 weeks or more of work.
My wysiwyg is gone as well after updating. Why did you remove this feature?
I got this to work but now what I need is results for Austin to show first then results for Houston.
$args = array(
'child_of' => '7',
'post__not_in' => array(2228),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'select_office_location',
'value' => '"Austin"',
'compare' => 'LIKE'
),
array(
'key' => 'select_office_location',
'value' => '"Houston"',
'compare' => 'LIKE'
)
),
'post_type' => 'page',
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'meta_value',
'posts_per_page' => '20',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
);
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.