Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing compatibility issues between The Events Calendar and WPML.

Solution:
We recommend adding the following code to your

functions.php

file:

/*<br />* WPML Workaround for compsupp-6815 (updated version for compsupp-7184)<br />*/<br />add_filter( 'tribe_rewrite_canonical_url', 'wpml_compsupp6815_resolve_missing_urls', 10, 3 );<br /><br />function wpml_compsupp6815_resolve_missing_urls( $resolved, $url, $object ) {<br /><br />    if ( class_exists('Sitepress') ) {<br />        $wpml_default_lang = apply_filters('wpml_default_language', NULL );<br />        $wpml_current_lang = apply_filters( 'wpml_current_language', NULL );<br />         <br />        // Let's register the calendar strings so we can translate and use in the workaround<br />        if ($wpml_default_lang == $wpml_current_lang ) {<br /><br />            $tec_options = get_option('tribe_events_calendar_options'); <br />            $events_slug = $tec_options['eventsSlug'];  <br />            $single_events_slug = $tec_options['singleEventSlug']; <br />                   <br />            do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($events_slug, 0, 20), $events_slug);<br />            do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($single_events_slug, 0, 20), $single_events_slug );<br />             <br />            foreach ($tec_options['tribeEnableViews'] as $calendar_string) {<br />                do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($calendar_string, 0, 20), $calendar_string);<br />            }<br />        }<br /> <br />        // Check if the URL is not resolved yet. If not, we will resolve it with the translated strings<br />        if ( preg_match( '#\(/\?\:([^)]+)\)#',  $resolved ) ) {<br /> <br />            $resolved = preg_replace_callback( '#\(/\?\:([^)]+)\)#', function($matches) use ($url) {<br />                $options = explode('|', trim($matches[0], '/(?:)'));<br />                 <br />                $slug = $options[0];                    <br /> <br />                $translated_slug = apply_filters('wpml_translate_single_string', $slug , 'the-events-calendar', 'TEC Calendar Slugs: '.substr($slug, 0, 20) );<br /> <br />                // Only apply the translation if the string already exists in the URL. If not, replace with the original. This may avoid possible 404 errors<br />                if (in_array(strtolower($translated_slug), $options) && $translated_slug != '') {<br />                    $slug = $translated_slug;<br />                } <br /> <br />                return $slug;<br /> <br />            }, $resolved );<br /><br />            // Check if there are parameters in the final result and correct the first "&" to "?"<br />            if (strpos($resolved, '&') !== false && strpos($resolved, '?') === false) {<br />                $resolved = preg_replace('/&/', '?', $resolved, 1);<br />            }<br />        }<br />    }<br /> <br />    return $resolved;<br />}<br />

After adding the code, navigate to Settings > Permalinks and re-save the settings.

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we encourage you to open a new support ticket. We also highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 18 replies, has 2 voices.

Last updated by Bobby 1 year, 3 months ago.

Assisted by: Bobby.

Author Posts
January 8, 2024 at 3:30 pm #15161380

arianeF-2

Hi! I have a problem of compatibility between The Events Calendar and WPML. I've contacted The Event Calendar Support and they have made many testo to our staging site, discovering the problem with WPML, so they asked to contact you to solve the problem if possible. I've seen a thread with a similar problem and applied the snippet you posted, but without success.

January 8, 2024 at 7:52 pm #15162476

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi Ariane,

If possible, please share with me some more details regarding the issue you are experiencing as well as the thread you opened with Event Calendar support (if it's public) and the thread you are referencing if you still have it, if not it's OK. 🙂

Also, please note we have 3 open issues with The Events Calendar at the moment, I invite you to review them.

Let me know if any of these fit the issue you are having

https://wpml.org/errata/the-events-calendar-recurring-event-instances-link-to-first-occurrence/

https://wpml.org/errata/the-events-calendar-tec-incorrect-event-urls-with-domain-per-language-url-format/

https://wpml.org/errata/the-events-calendar-pro-event-series-new-feature-integration/

January 10, 2024 at 5:21 am #15167214

arianeF-2

Hi Bobby, here's Max, managing the problem for Ariane.

I think my problem is the one described in this issue: https://wpml.org/errata/the-events-calendar-date-link-points-to-monthmonatmiesic/

On our live site hidden link you can see that the "next events" links on the calendar are not working and the links that point to are similar to the one described by your support issue.

I've tried to apply the solution suggested but still not working.

January 10, 2024 at 9:53 pm #15171769

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

I would like to request temporary access (wp-admin and FTP) to your site to test the issue.
(preferably to a test site where the problem has been replicated if possible)

**Before we proceed It is necessary to take FULL BACKUP of your database and your website. By providing us with access, you agree that a backup has been taken **

I often use the Duplicator plugin for this purpose: http://wordpress.org/plugins/duplicator/
You will find the needed fields for this below the comment area when you log in to leave your next reply.
The information you enter is private which means only you and I have access to it.

NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin.

Thank you,
Bobby

January 17, 2024 at 7:45 am #15192904

arianeF-2

Hi Bobby,
sorry for the delay.

We preferred to create a Duplicator backup of the production site and send it to you to avoid problems with Staging or Production site.

You can download it from this link: hidden link

Thanks in advance.

Max

January 19, 2024 at 8:57 pm #15206346

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi Max,

Thank you for sharing this with me, unfortunately, I am not able to deploy it as it's missing the duplicator files, and looks like I only got an SQL file.

Please verify and update me.

January 24, 2024 at 10:03 pm #15224075

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the duplicator package! I was able to resolve this following the steps from https://wpml.org/errata/the-events-calendar-date-link-points-to-monthmonatmiesic/

a few things:

1. First update WP and the WPML plugins along with the Event Calendar plugin to their latest versions

2. Follow the steps from the errata here 1 by 1 and apply the code in the functions.php

3. Once #2 is done, go to WPML->String Translation and search for "Month" , check the box for both Exact match and Include translations

Make sure that all strings are fully translated and not one translation is missing

Do this for Month, List, and Day

Let me know your results, please.

Screen Shot 2024-01-24 at 2.02.18 PM.png
January 31, 2024 at 5:13 am #15247228

arianeF-2

Hi Bobby,
thank you for your kind answer.

I've tried your solution step by step on the production site hidden link but without any progress... as you ca see the "next event" butto on calendar modulo on home page still doesn't work properly, not showing future events.

If you agree I can create a copy of the production site on a staging domain and create an admin account for you, or grand admin access to the production site.

Thanks in advance.

January 31, 2024 at 6:27 pm #15251172

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for updating me!

Yes, it is up to you, either one is ok with me as long as there is a full backup in place before accessing the site.

Private reply enabled

February 1, 2024 at 10:08 pm #15257123

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Thank you for the access details!

I have performed all the steps from the errata on your site step by step.

Looks like the issue is still happening on the site, therefore I migrated a copy to our staging servers on Cloudways to further investigate, however, the issue cannot be reproduced here.

hidden link

Please clear the site's cache and/or deactivate any object caching or server side caching, as well as asking your hosting provider to clear the cache from their side as well.

Additionally verify that no drop in caching is actived.

February 2, 2024 at 5:03 pm #15260398

arianeF-2

HI Bobby

on your staging server seems that the theme is not working correctly, I see all broken.

I've tried to clear cache on the website and also deactivate che caching plugin but nothing changes.

The hosting answered to us that there is not server cache on our site.

Looking forward for your further investigations... if you need support from me just ask.

Thanks in advance!

Max

February 3, 2024 at 10:48 pm #15262806

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

I was able to fix and reproduce the issue on our staging site.

I escalated this thread to our 2nd tier support and they will take a look at this issue.

You will be notified as soon as new information is available.

Thank you,
Bobby

February 15, 2024 at 4:35 am #15304882

arianeF-2

Hi Bobby,
does the 2nd Tier Support will continue tu communicate with my using this thread? Because the customer is out of office for a couple of week so she cannot forward me e-mail they eventually send to her....

Thank you in advence

Max

February 15, 2024 at 4:37 am #15304912

arianeF-2

Hi Bobby,

does the 2nd Tier Support will continue to communicate using this thread? Because the customer will be out of office for a couple of weeks and she cannot forward me eventual email they can send to her.

Thanks in advance.

Max

February 16, 2024 at 1:59 am #15309842

Bobby
WPML Supporter since 04/2015

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi Max,

Please try the following updated code, add it to your functions.php file:

/*
*  WPML Workaround for compsupp-6815 (updated version for compsupp-7184)
*/
add_filter( 'tribe_rewrite_canonical_url', 'wpml_compsupp6815_resolve_missing_urls', 10, 3 );
 
function wpml_compsupp6815_resolve_missing_urls( $resolved, $url, $object ) {
 
    if ( class_exists('Sitepress') ) {
        $wpml_default_lang = apply_filters('wpml_default_language', NULL );
        $wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
         
        // Let's register the calendar strings so we can translate and use in the workaround
        if ($wpml_default_lang == $wpml_current_lang ) {

            $tec_options = get_option('tribe_events_calendar_options'); 
            $events_slug = $tec_options['eventsSlug'];  
            $single_events_slug = $tec_options['singleEventSlug']; 
                   
            do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($events_slug, 0, 20), $events_slug);
            do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($single_events_slug, 0, 20), $single_events_slug );
             
            foreach ($tec_options['tribeEnableViews'] as $calendar_string) {
                do_action( 'wpml_register_single_string', 'the-events-calendar', 'TEC Calendar Slugs: '.substr($calendar_string, 0, 20), $calendar_string);
            }
        }
 
        // Check if the URL is not resolved yet. If not, we will resolve it with the translated strings
        if ( preg_match( '#\(/\?\:([^)]+)\)#',  $resolved ) ) {
 
            $resolved = preg_replace_callback( '#\(/\?\:([^)]+)\)#', function($matches) use ($url) {
                $options = explode('|', trim($matches[0], '/(?:)'));
                 
                $slug = $options[0];                    
 
                $translated_slug = apply_filters('wpml_translate_single_string', $slug , 'the-events-calendar', 'TEC Calendar Slugs: '.substr($slug, 0, 20) );
 
                // Only apply the translation if the string already exists in the URL. If not, replace with the original. This may avoid possible 404 errors
                if (in_array(strtolower($translated_slug), $options) && $translated_slug != '') {
                    $slug = $translated_slug;
                } 
 
                return $slug;
 
            }, $resolved );

            // Check if there are parameters in the final result and correct the first "&" to "?"
            if (strpos($resolved, '&') !== false && strpos($resolved, '?') === false) {
                $resolved = preg_replace('/&/', '?', $resolved, 1);
            }
        }
    }
 
    return $resolved;
}

Go to Settings > Permalinks and re-save again.

Once done let me know your results, please