Home › Forums › Calendar Products › Events Calendar PRO › Event Categories
- This topic has 3 replies, 2 voices, and was last updated 7 years, 7 months ago by
dolsonsyc427.org.
-
AuthorPosts
-
August 1, 2018 at 4:41 pm #1588121
dolsonsyc427.org
ParticipantIs there a way to customize the order categories List out? I have 5 children categories that display in alphabetical order, but I need them to display in order of grades. Kindergarten, First Grade, Second Grade, Third Grade, Fourth Grade, Fifth Grade.
Thanks!
August 3, 2018 at 8:38 am #1589593Sky
KeymasterHi there,
Thanks for reaching out. I will try to help with your question.
Can you tell me where you would like the categories to have this custom order? Where are you seeing this list of categories?
Thanks,
SkyAugust 20, 2018 at 11:51 am #1601467dolsonsyc427.org
ParticipantHi Sky,
Here’s a link to one of our calendars.
I would like them to go in order of grade. Kindergarten, First Grade, Second Grade, etc.
Thanks!
August 21, 2018 at 8:04 am #1602098Sky
KeymasterHi there,
Thanks for reaching out. I’d be happy to help with your question! Please note that we are a bit limited in the amount of support that we can provide for customizations here in the forums. That being said, I will try to get you pointed in the right direction.
There is unfortunately not a way built in to the plugin to create a custom order for the categories in the filterbar. It is possible to achieve, but it will take a bit of customization using PHP.
There is a WordPress “filter” on the output of each filter in the filterbar. We can use this to provide a custom value for the list of categories. We also have access to the filter name, which we can use to make sure we only replace the one we want.
Here is a snippet showing how to replace the values with our own:
add_filter( 'tribe_events_filter_values', 'testing_tribe_filters', 100, 2 );
function testing_tribe_filters($items, $slug) {
if( $slug === 'eventcategory'){
// provide custom order for $items array here
$items = $new_items_array
}
return $items;
}
All that’s missing is to create the new array of categories and assign it to $items. This may be tricky because you have several top level categories, and you would need to either hard code the entire list with all the required data for each, or apply some logic here to re-order everything.
Here’s what the structure of the array looks like:
Array (
[0] => Array (
[name] => Category Name,
[depth] => 0,
[value] => 42,
[data] => Array (
[slug] => category-name
),
[class] => tribe-parent-cat tribe-events-category-category-name
),
)
I hope that helps! Please let me know if you have any additional questions about this.
Thanks,
SkySeptember 12, 2018 at 9:35 am #1619669Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Event Categories’ is closed to new replies.
