Help Desk

Hook into Filter Bar's "Event Category" to achieve WPML translation

  • Posts: 32 Topics: 18
    | Permalink

    Hiya. My site is English/French bilingual, and WPML and TEC play nicely together 99% of the time.

    The one exception I’m finding is in the Filter Bar add-on, in having my Event Categories be translated. I can’t find any option to do this in the Settings panel, and the typical WPML toggle doesn’t work.

    So, I thought I could hook into the filter that displays the Category names, and change them to French as needed.

    I already have this code in my functions.php file to change the title that appears about the Event Category, if the user is viewing the page in French:

    if( ICL_LANGUAGE_CODE=='fr') {
    	function tribe_change_filterbar_filter_title ($title) {
    	if ($title == 'Event Category') {
    	$title = 'French-Title-Here';
    	return $title;
    	add_filter('tribe_events_filter_title', 'tribe_change_filterbar_filter_title');

    I’m hoping there’s something similar for I can do to change the names of the categories that appear in the Filter Bar. Or is there an easier way to have those Event Categories save in both languages?

    (My calendar is at http://my-site/calendar)

    (Apologies if my terminology is off; I’m new to hooks/filters/actions).

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink
    Correct Answer

    Hi Sean:

    The values used to populate any filter – including the categories filter – can themselves be filtered (using a filter in the WordPress sense, that is):

    add_filter( 'tribe_events_filter_values', 'customize_cat_filter_values', 10, 2 );
    function customize_cat_filter_values( $values, $filter_slug ) {
        // Only interfere with the category filter
        if ( 'eventcategory' !== $filter_slug ) return;
        // Loop through the values and modify them
        foreach ( $values as &$single_value ) {
            // Obviously, change the following line to actually translate the text
            // using whatever means are appropriate/easiest here
            $single_value = "ALTERED $single_value";

    The above highlights the basic sort of strategy you might use (and could be added either to a custom plugin or your theme’s functions.php file, depending on your preferences).

    I hope that helps!

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks

    Posts: 3443 Topics: 13 Answers: 199
    | Permalink


    We are excited to report that our upcoming release, The Events Calendar 3.12, includes changes that greatly improve the compatibility between The Events Calendar and WPML. We’ve been working hard on this integration for some time and we want to specifically thank all of our users who requested and waited for this feature. We appreciate all of the support and patience!

    Version 3.12 of The Events Calendar will greatly improve compatibility with WPML, but we still have work to do. If you run into any problems integrating the two plugins, please post in our forums so that we can look into the issues. We’ll be on the look out for tweaks and fixes that will improve things further.

    Thank you again to everyone who has been waiting for this! The Events Calendar 3.12 is coming soon- watch your WordPress Updates page!

    and The Events Calendar team