Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - -
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

Tagged: 

This topic contains 7 replies, has 0 voices.

Last updated by Christopher Amirian 11 months, 2 weeks ago.

Assisted by: Christopher Amirian.

Author Posts
May 15, 2025 at 8:33 am

adrianM-2

Background of the issue:
I am trying to resolve an issue with my site cyrkus.eu, which has almost 1000 404 errors. The problem seems to be related to unresolved strings in URLs, specifically with the translation of 'month' in different languages. I have worked with 'The Events Calendar' support team, who suggested using 'Loco Translate' to remove special characters from the Polish translation of 'month' and then saving the permalinks. This solution worked on the staging site but not on the live site. I have also tried setting the live site to PHP 8.4, but the issue persists. Here are the relevant links: hidden link, hidden link, and hidden link?:%5B/%5D.

Symptoms:
The URLs on the live site and new staging site are not resolving correctly, showing patterns like (/?:month|monat|miesiac)/ and ending with letters and a % sign, such as hidden link?:%5B/%5D.

Questions:
Can you help me resolve the URL string resolution issue on my live site?
Why does the solution that worked on the staging site not work on the live site?

May 15, 2025 at 1:36 pm #17037150

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

We tried to create a duplicator package of the website but unfortunately there is a memory limit shortage.

Would you please make sure that the hosting has at least 512M PHP memory limit and also please add the code below to wpo-config.php file in your WordPress installation.
You can add this by adding the code below to "wp-config.php" file of your WordPress installation root folder:

/** Memory Limit */
define('WP_MEMORY_LIMIT', '512M');
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Please add the code above the line below:

/* That's all, stop editing! Happy blogging. */

Thanks.

May 27, 2025 at 1:12 pm #17078644

adrianM-2

Hi Christopher,

I'm sorry, I didn't see the reply.

I've increased the memory limit.

It would be great if you could send me a quick notification to info@findefux.net when you get a reply.

Thank you very much
Mandy

May 27, 2025 at 3:00 pm #17079352

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi Mandy,

Thank you. I managed to create a duplicator package and reported this to our second tier support.

Please consider that it may take time for a reply and unfortunately we can not send separate emails each time we give a reply.

The automatic emails go to the email that has wpml.org account.

I will get back to you if I have news.

Thanks.

May 28, 2025 at 1:01 pm #17083541

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

I have an answer from the second tier support. For your specific scenario, we had to change the regular expression in the helper function we suggested in errata.

If you check now it works ok:

hidden link

We changed this code:

		if ( preg_match( '#(/?:([^)]+))#',  $resolved ) ) {

			$resolved = preg_replace_callback( '#(/?:([^)]+))#', function($matches) use ($url) {

To:

if ( preg_match( '#/\(([^)]+)\)#', $resolved ) ) {

    $resolved = preg_replace_callback( '#/\(([^)]+)\)#', function($matches) use ($url) {

You can grab the whole code from the functions.php file of your theme on the staging website and apply it to your live website.

Thanks.

June 2, 2025 at 9:06 am #17097038

adrianM-2

Hello,

thank you for your message.

What do you mean when you say it's working now? When I click on "Aktualny miesiąc" in the staging, the expression still doesn't resolve (see screenshot). I can't find the code you described in either the functions.php of my child theme or my theme. Is the code really in "functions.php" in my theme folder? Or did you add it somewhere else?

Best regards, Mandy Kriese

Bildschirmfoto 2025-06-02 um 11.02.33.png
June 2, 2025 at 9:29 am #17097210

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Thanks, the code is inside the functions.php file of the 2021 theme which we are testing now.

But I do see that some links are not fixed yet. I asked the second-tier support and will get back to you.

June 2, 2025 at 2:54 pm #17098500

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Ok please add this code to your functions.php file of the theme:

/*
*  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;
}

Also please check this video:

hidden link

The topic ‘[Closed] The Events Calendar – Calendar Link points to (/?:month|monat|miesic|….)’ is closed to new replies.