Last active
August 29, 2015 14:09
-
-
Save elimn/755ab345963c7469075c to your computer and use it in GitHub Desktop.
MT | TEC | Set Events Category Default View
This file contains 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 | |
// Overrides every request for viewOption from TribeEvents::getOption() | |
function tribe_swap_default_category_view ($option, $default, $optionName) { | |
// For a list of acceptable views/values run print_r(tribe_events_enabled_views()); | |
$default_events_view = 'month'; // The default view for the main page, venue, etc. | |
$default_category_view = 'list'; // The default view for any calendar category | |
if ($optionName === 'viewOption') { | |
// Default category view is saved as a rewrite rule | |
// Every other view checks viewOption on front-end page load | |
// Hack: Since rewrites are usually only saved/flushed from the admin area, check that | |
if( is_admin() ) { | |
$option = $default_category_view; | |
} else { | |
$option = $default_events_view; | |
} | |
} | |
return $option; | |
} | |
add_filter('tribe_get_single_option', 'tribe_swap_default_category_view', 1, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment