[Resolved] Compatibility issue with the events calendar
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.
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.
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
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.
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 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.
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.
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.
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....
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.
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
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.