Skip to content Skip to sidebar

Waiting for author

Topic Tags: Compatibility

Overview of the issue

If you are using The Events Calendar plugin, you may encounter issues with event calendar links redirecting incorrectly, displaying patterns like (/?:month|monat|miesic|…).

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following code:
    /*
    *  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;
    }
    
  • Then, go to Settings > Permalinks and resave your permalinks.

Note: if the issue remains, please open a chat in our assistance channel.

4 Responses to “The Events Calendar - Link points to (/?:month|monat|miesic|....)”

    • Hello,
      Thanks for reaching out. I’ve checked the internal ticket, and the fix needs to be implemented by the Events Calendar authors. I can’t provide an ETA at the moment, but as soon as they confirm the issue is resolved on their end, we’ll update this page and mark it as “resolved”.

  1. In my case, this solution doesn’t work. I can only navigate to the next event list page (in the second language) once, and when I try to click the arrow again, nothing happens. Have you any ideas why it’s not working?

    • Hello there,

      This is a known complex issue that can happen in different scenarios and hasn’t been fully resolved by the plugin authors.

      Could you please open a ticket on our support forum? That way, our team can investigate further and assist you directly.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>