Skip to content

Instantly share code, notes, and snippets.

@BeardedGinger
Created April 14, 2015 13:25
Show Gist options
  • Select an option

  • Save BeardedGinger/4d5174081842fe78cebb to your computer and use it in GitHub Desktop.

Select an option

Save BeardedGinger/4d5174081842fe78cebb to your computer and use it in GitHub Desktop.
Filter Community Events Event Category $args
<?php
add_filter( 'tribe_community_events_event_categories', 'ce_fe_cats_order', 100 );
/**
* Filter the $args for the event category option on the front-end form of Community Events
*/
function ce_fe_cats_order( $args ) {
$event_cat_ids = (array) $currently_selected;
if ( ! empty( $event->ID ) && empty( $currently_selected ) ) {
$event_cats = wp_get_object_terms( $event->ID, TribeEvents::TAXONOMY );
foreach ( $event_cats as $event_cat ) {
$event_cat_ids[] = $event_cat->term_id;
}
} elseif ( !empty( $currently_selected ) ) {
$args = array(
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
'include' => $event_cat_ids,
);
$event_cats = get_terms( TribeEvents::TAXONOMY, $args );
} else {
$event_cats = array();
}
$args = array(
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
'exclude' => $event_cat_ids,
);
// Could have used wp_terms_checklist(), but it didn't have the customizability required.
$cats = get_terms( TribeEvents::TAXONOMY, $args );
$cats = array_merge( $event_cats, $cats );
return $cats;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment