Skip to content

Instantly share code, notes, and snippets.

@MikeNGarrett
Forked from jo-snips/event-category-list.php
Created August 5, 2012 23:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeNGarrett/3268062 to your computer and use it in GitHub Desktop.
Save MikeNGarrett/3268062 to your computer and use it in GitHub Desktop.
The Events Calendar: List Event Categories
<?php // If you'd rather have category drop downs ?>
<form action="#" method="get" id="event-change">
<?php
$current = get_query_var('tribe_events_cat');
$terms = get_terms($tribe_ecp->get_event_taxonomy());
$count = count($terms);
if ( $count > 0 ){
echo '<select class="events-cat-menu"><option value="-1">All Events</option>';
// print_r($terms);
$selected = '';
foreach ( $terms as $term ) {
if($current == $term->slug) { $selected = 'selected="selected"'; }
echo '<option value="'. get_term_link($term->slug, 'tribe_events_cat') .'" '.$selected.'>' . $term->name .'</option>';
$selected = '';
}
echo '</select>';
}
?>
<noscript>&lt;input type="submit" value="&amp;rarr;"&gt;</noscript>
</form>
<script type="text/javascript">
jQuery(document).ready(function($){
$('.events-cat-menu').change(function() {
location = $(this).val();
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment