Query for future Events

According to this Article:


Thanks for Post! I am fascinated about query-stuff for Event Manager.

Now, i need to filter also the Category but this is not working for me:

post_type=event&category_name=highlight_des_monats&posts_per_page=4&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Y-m-d”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

Can you give me little help for this, please…

Regards,
Christian

Hello Christian,

Thanks for writing to us.

You need to add the tax query in the query string, I would suggest you have a look at the given below query strings.

 post_type=event&post_status=publish&tax_query%5B0%5D%5Btaxonomy%5D=YOUR_TAXONOMY_NAME&tax_query%5B0%5D%5Bterms%5D=8888&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Y-m-d”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D 

Please change the taxonomy name as per your requirement and you need to add the term ID in place of the demo term ID 8888.

Thanks

Hi, thanks for your help!
I did, but its not working for me…whats wrong?

post_type=event&post_status=publish&tax_query%5B0%5D%5Btaxonomy%5D=highlight_des_monats&tax_query%5B0%5D%5Bterms%5D=32&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Y-m-d”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

kindly regards, Christian

Hey @cyrock,

Would you mind sharing your admin credentials so that we can check your setup properly? To do that, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password

You can find the Secure Note button at the bottom of your posts.

Thank you.

Hi, thanks…i did, see above :slight_smile:

Hello @cyrock,

You have to use this argument instead:

$tax_query[] = array(
   'tax_query' => array(
       array(
            'taxonomy' => 'event-categories',
            'field'    => 'slug',
      		'terms'    => 'highlight_des_monats',
	        //'operator' => 'IN',
       )
   ),
);

$meta_query[] = array(
	'key'     => '_event_start_date',
	'value'   => date('Y-m-d'),
	'compare' => '>=',
);

$query = array(
	'post_type' => 'event',
	'posts_per_page' => '4',
	'post_status'  =>  'publish',
	'meta_key' => '_event_start_date',
	'orderby' => 'meta_value',
	'order' => 'ASC',
	'offset' => '0',
	'meta_query' => $meta_query,
	'tax_query'  => $tax_query
);

Kindly let us know how it goes.

[details=“Summary”]
Hi, Thanks for this…! Can you convert this to a string, please. Then I can use it in “Query String”, thanks a lot
regards,
christian[/details]

Hello @cyrock,

Please have a look at the given below query strings. Please have a look at this doc to learn more about how to use query string and convert the query into query string

post_type=event&posts_per_page=4&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D=2023-04-01&meta_query%5B0%5D%5Bcompare%5D=%3E%3D&tax_query%5B0%5D%5Btax_query%5D%5B0%5D%5Btaxonomy%5D=event-categories&tax_query%5B0%5D%5Btax_query%5D%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Btax_query%5D%5B0%5D%5Bterms%5D=highlight_des_monats 

Thanks

Hi, thanks for this…i tried to get through, but have no experience yet. The string you sent ist unfortunately not working…past events are not disapearing after start date has passed.

This one works fine, but i can´t filter categories:
post_type=event&posts_per_page=4&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Y-m-d”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

Thanks,
Christian

ps. tried this one accotding to your lines, with no result:
0%5Btax_query%5D%5B0%5D%5Btaxonomy%5D=event-categories&0%5Btax_query%5D%5B0%5D%5Bfield%5D=slug&0%5Btax_query%5D%5B0%5D%5Bterms%5D=highlight_des_monats0%5Bkey%5D=_event_start_date&0%5Bvalue%5D=2023-04-06&0%5Bcompare%5D=%3E%3Dpost_type=event&posts_per_page=4&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D=2023-04-06&meta_query%5B0%5D%5Bcompare%5D=%3E%3D

Hello @cyrock,

You can test this out:
post_type=event&posts_per_page=4&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Y-m-d"}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D&meta_query%5B0%5D%5Btype%5D=DATE

Or this one:
post_type=event&posts_per_page=4&post_status=publish&meta_key=_event_start_date&orderby=meta_value&order=ASC&offset=0&meta_query%5B0%5D%5Bkey%5D=_event_start_date&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format="Y-m-d"}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D&meta_query%5B0%5D%5Btype%5D=DATE&tax_query%5B0%5D%5Btax_query%5D%5B0%5D%5Btaxonomy%5D=event-categories&tax_query%5B0%5D%5Btax_query%5D%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Btax_query%5D%5B0%5D%5Bterms%5D=highlight_des_monats

Kindly let us know how it goes.

Hi,
there…sorry for late response. Thanks a big lot for your Help!
This works fine for me!

kind regards,
Christian

You are most welcome, @cyrock.

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