Past Events/Future (Current Events) out of order in Query Builder

Hey @3HExapaT,

Great and let us know how it goes.

Thank you.

Hi, I’ve had no luck with Events Manager. Are there any Event plugins that work well with Pro?

Hello @3HExapaT,

You can use the Modern Events Calendar plugin. You can check out this documentation:

By the way, you should not be using the Looper Provider Query Builder. You need to use the Looper Provider Query String and query the needed date of the event. Perhaps this old thread can help you instead as your reference:

Best Regards.

Thanks for sending this over.

I haven’t worked in Query Strings before. I found a query string related to Events Manager and tried it out. Unfortunately it didn’t work. Do you have any suggestions on setting this up for Events Manager?

Thank you!

I was able to create a query string that brought in all the events and put them in descending order. However, it’s pulling in all posts and not those prior to the current date/time. This is what I have so far: post_type=event&posts_per_page=99&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=DESC

Any tips on pulling data prior to the current date/time in CMT? Will also need to do this for future events.

Hello @3HExapaT,

Following this thread, Best Practice? Looper with custom meta date, and then modify it to suit with the Events Manager, you will have something like this:

$meta_query[] = array(
    'key'     => '_event_start_date',
    'value'   => date('Ymd'),
    'compare' => '>=',
);

$query = array(
    'post_type'  => 'event',
    'meta_key'   => '_event_start_date',
    'orderby'    => 'meta_value',
    'order'      => 'ASC',
    'meta_query' => $meta_query
);

And by using the @Kory’s solution from this article (Looper Query String: Featured Products), you should be getting this query string:
post_type=event&meta_key=_event_start_date&orderby=meta_value&order=ASC&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D=20220624&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

where the “20220624” is the date of today. And to get the current Date, you will have to use the dynamic content date “ {{dc:global:date format="Ymd"}} ” which will then gives you:

post_type=event&meta_key=_event_start_date&orderby=meta_value&order=ASC&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Ymd"}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

This may not work out of the box and serves as a mere example of how you can work with the Looper Provider Query String. You can manipulate the sample query above to get the past and/or future events.

Best Regards.

Thanks for looking at this for me. I’m still getting the same results in the data. I’ve added &meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Ymd”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D to my query so it is now: post_type=event&posts_per_page=99&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=DESC&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Ymd”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

Any ideas on what may be incorrect in this?

Here is a link to the page showing the results: https://laialoha.org/lai-events/past-events/

Hey @3HExapaT,

After further investigation, you should be using this Query instead:

$meta_query[] = array(
    'key'     => '_event_start_date',
    'value'   => date('Ymd'),
    'compare' => '<',
	'type' => 'DATE'
);

$query = array(
    'post_type'  => 'event',
    'meta_key'   => '_event_start_date',
    'orderby'    => 'meta_value',
    'order'      => 'DESC',
    'meta_query' => $meta_query
);

which will then give you this string:
post_type=event&meta_key=_event_end_date&orderby=meta_value&order=DESC&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D=20220625&meta_query%5B0%5D%5Bcompare%5D=%3C&meta_query%5B0%5D%5Btype%5D=DATE

Kindly let us know how it goes.

This look good. Will it dynamically adjust to the current date? It looks like the date is hard coded so it would need to be manually changed. 20220625

It looks like the event links are blank and go to the home page. Any way to fix that?

Can this also be set for current events? So it only shows events in the future?

Hi @3HExapaT,

By withdrawing the post, I believe you already have resolved the issue. If the issue still existed, you can let us know.

Thanks.

Sorry, had several questions in a row. Removed them and condensed to the first one. Copying below:

Will it dynamically adjust to the current date? It looks like the date is hard coded so it would need to be manually changed. 20220625

It looks like the event links are blank and go to the home page. Any way to fix that?

Can this also be set for current events? So it only shows events in the future?

Hey @3HExapaT,

To your question:

Yes, it will get the current date.

The event links are not blank. It looks like all your events redirects to the home page. I’ve visited your event link directly and I’m redirected to the home page. Try this link: https://laialoha.org/events/military-land-use-and-more/. It’s not the builder doing that. You might have set up redirection using a 3rd party plugin or have a custom function that does the redirection.

It can. However, it would require further edits to the query and as my collegue mentioned, it’s only a sample. Users must learn how to use the WP Query. In case that’s hard for you, you might want to subscribe to our One premium support where we cover a wide range of WordPress topics including WP Query guidance. WP Query is not specific to Pro, by the way. It’s under general WordPress topic.

Thanks.

Yes, it will get the current date.

How will the Query deliver the date in the future when it is set for 20220625? I’ve looked over the WP Query link you sent and I’m not finding any info related to setting a dynamic data pull for the current date. Does this Query string need to be updated daily to pull posts added after June 25, 2022? Thanks for your patience. I’m new to this.

It looks like the event links are blank and go to the home page. Any way to fix that?
It seems to be working now. Not sure what happened, but it’s working fine.

Thanks for your help.

Hey @3HExapaT,

Please go back to my reply here:

To get the current Date, you will have to use the dynamic content date “ {{dc:global:date format="Ymd"}} ” which will then gives you:
post_type=event&meta_key=_event_end_date&orderby=meta_value&order=DESC&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Ymd"}}&meta_query%5B0%5D%5Bcompare%5D=%3C&meta_query%5B0%5D%5Btype%5D=DATE

Hope this makes sense.

I was able to figure out Future/Current events also. This is working great. Thanks for your guidance. This can be closed.

Hey There,

We are really glad that you were able to resolve your issue. Please feel free to create another thread if you need any other help and information.

Cheers.

I am Ivan, one of the developers at Webnus. During our time as a member of the WordPress community, we have made a few mistakes. One of our developers requested a test drive and provided his email address so that the user could send his information to it. However, as we all know, WordPress guidelines prohibit posting company and official email addresses in the community forum.

WordPress volunteers, who are in charge, did not accept our admission of guilt and apology this time.

As many of our users and supporters have come to the shocking realization that MEC Lite has been removed from the WordPress repository alongside our other plugins and themes, we too have been dealing with the blowback from this sudden, unilateral decision, with no recourse to challenge it in the immediate future. Our first step was to issue a new update for MEC Lite on our website (since it is the most popular of all our products) so that our users don’t miss out on future updates and improvements that MEC Pro users receive.

Download the Lite Version
https://webnus.net/modern-events-calendar/lite/

We still hold out hope that the WordPress team will revise their decision in the short to near term future. Hopefully one day their policy regarding permanently banning loyal and helpful WordPress members will be changed to something more reasonable as we didn’t do anything malicious to deserve that hit.

Hi Ivan,

Thanks for the information and direct download link.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.