Last active
          October 24, 2017 09:01 
        
      - 
      
- 
        Save zartgesotten/190fc9487b828c114820a7815a540a78 to your computer and use it in GitHub Desktop. 
    Creates a dropdown with all event categories
Has to be added to template where the dropdown should be displayed. Sources: https://theeventscalendar.com/support/forums/topic/category-dropdown/
https://pastebin.com/jg2hr5yz
  
        
  
    
      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 | |
| $categories = get_categories( | |
| array( | |
| 'taxonomy' => TribeEvents::TAXONOMY, | |
| 'selected' => 0, | |
| 'orderby' => 'name' | |
| ) ); | |
| ?> | |
| <script type="text/javascript"><!-- | |
| function onCatChange(select) { | |
| var slug = select.options[select.selectedIndex].value; | |
| var link = '<?= tribe_get_events_link() ?>'; | |
| location.href = (slug == 'all') ? link : link + 'category/' + slug; | |
| } | |
| --></script> | |
| <select id="categories" onchange="onCatChange(this)" > | |
| <option value="all">All Events</option> | |
| <?php | |
| foreach ($categories as $cat) { | |
| if (tribe_meta_event_category_name() == $cat->name) $selected='selected'; | |
| else $selected = ''; | |
| ?> | |
| <option value="<?= $cat->slug ?>" <?= $selected ?>><?= $cat->name ?></option> | |
| <?php } ?> | |
| </select> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment