Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_specified_month($uri) {
- // Look for patterns like 2099-12 at the end of the URI
- $month_pattern = '[0-9]{4}-[0-9]{2}';
- $optional_slash = '/?';
- $pattern = "#($month_pattern)($optional_slash)$#";
- // Check for matches
- $match = array();
- if (preg_match($pattern, $uri, $match) !== 1) return false;
- // We are interested only in the year/date portion
- return $match[1];
- }
- function upcoming_single_month_view(WP_Query $query) {
- // We are only interested in requests to view upcoming events
- if ($query->query_vars['eventDisplay'] !== 'upcoming') return;
- // Has a specific month been specified?
- $month = get_specified_month($_SERVER['REQUEST_URI']);
- if ($month === false) return;
- // Set the start date, end date
- $args = &$query->query_vars;
- $args['start_date'] = $month.'-01';
- $args['end_date'] = $month.'-31';
- return $query;
- }
- // We'll run our filter later than TribeEventsQuery::setArgsFromDisplayType()
- add_filter('parse_tribe_event_query', 'upcoming_single_month_view', 20);
Advertisement
Add Comment
Please, Sign In to add comment