Created
January 30, 2020 21:44
-
-
Save wplit/51b117591e3b26bef611e745da2c2a6e to your computer and use it in GitHub Desktop.
filter query for events that are in future
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'pre_get_posts', 'lit_event_date_filter' ); | |
| function lit_event_date_filter($query) { | |
| $date_now = date('Ymd'); | |
| $query->set( 'meta_query', array( | |
| array( | |
| 'key' => 'event_date', | |
| 'compare' => '>', | |
| 'value' => $date_now, | |
| 'type' => 'DATETIME' | |
| ) | |
| ) | |
| ); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment