Forums › Global Maps › Events Calendar posts – hide past events
Tagged: The Events Calendar
- This topic has 6 replies, 3 voices, and was last updated 6 years, 6 months ago by
adam-stephensbaseassociates-co-uk.
-
AuthorPosts
-
January 22, 2016 at 2:40 am #50229
Hi, I’m using the Global Maps tool to display The Events Calendar Events custom post type but I only want to have events come up in the map that haven’t taken place yet. Is there a function I can use to hide past events from showing up without having to hack the plugin? Thanks.
January 28, 2016 at 10:09 pm #50378Chris Homan
MemberI’d be very interested in hearing about this as well. Any progress on this?
January 28, 2016 at 10:43 pm #50379Eyal Fitoussi
MemberHi,
The Global Maps add-on uses the WP_Query class to query the results. You need to filter the WP_Query based on the date, which I believe is saved in custom fields, and show only events that equal or later than todays date.The filter you can use is:
1apply_filters( 'gmaps_gmpt_form_before_posts_query', $this->form );and can be found in
omw-global-maps/posts/includes/gmaps-query-functions.php
.You can check the codex for information regarding WP_Query.
Also, this article has few examples regarding WP_Query and at the button of the page there is the “Real World Example” which filter post types events based on the date.
I hope that helps.
January 28, 2016 at 10:46 pm #50380Eyal Fitoussi
MemberThere is one thing you will need to do if you are going to filter the WP_Query.
In the file:
gmw-global-maps/posts/includes/gmaps-query-functions.php
You need to remove line 499 which should be:
1$this->form['advanced_query'] = false;This work around can only be done by editing the code file but in a future update I will fix that.
January 29, 2016 at 2:08 am #50396Thanks for getting back to me. So if I add the below code to my themes functions file, would that work:
add_filter( 'eventDisplay', array( $this, 'upcoming' ) );
January 29, 2016 at 8:47 pm #50411Eyal Fitoussi
MemberHi Adam,
The above will not work.You need to create a custom function that filters the WP_Query based on your needs. It required some PHP and WordPress filters knowledge.
Below is an example of how to create a custom function and execute it using the filter. But you will need to modify the query arguments based on your needs within that function. Thats where you could look in the links I mentioned above for some ideas of how to do that.
1234567function gmw_filer_events_by_date( $gmw ) {// this is where your custom filtering should go.return $gmw;}add_filter( 'gmaps_gmpt_form_before_posts_query', 'gmw_filer_events_by_date' );January 30, 2016 at 5:55 am #50420Hi,
I’m not very familiar with filters – what I’m trying to do is add the following wp_query property to the array in the gmaps-query-functions.php file:
'eventDisplay' => upcoming
Could you possibly give an example of how the above can be added with your filter in my theme functions file?
Thanks.
-
AuthorPosts
The topic ‘Events Calendar posts – hide past events’ is closed to new replies.