SHOW:
|
|
- or go back to the newest paste.
| 1 | add_action('parse_query', 'use_list_view_for_categories', 60);
| |
| 2 | ||
| 3 | function use_list_view_for_categories($query) {
| |
| 4 | // Run once | |
| 5 | remove_action('parse_query', 'use_list_view_for_categories', 60);
| |
| 6 | ||
| 7 | - | // Don't interfere unless this is a request for a Tribe category and it is not already for list view |
| 7 | + | // Interfere only for non-ajax Tribe category requests not already destined to be presented by list view |
| 8 | if (defined('DOING_AJAX') && DOING_AJAX) return;
| |
| 9 | if (!isset($query->tribe_is_event_category) || !$query->tribe_is_event_category) return; | |
| 10 | if (tribe_is_view('upcoming')) return;
| |
| 11 | ||
| 12 | // Obtain the query term and get a link to list view for that term | |
| 13 | $main_tax_query = $query->tax_query->queries[0]; | |
| 14 | $term = get_term_by('slug', $main_tax_query['terms'][0], TribeEvents::TAXONOMY);
| |
| 15 | $link = tribe_get_listview_link($term->term_id); | |
| 16 | ||
| 17 | // Try to redirect | |
| 18 | wp_redirect($link); | |
| 19 | exit(); | |
| 20 | } |