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 4 replies, has 2 voices.

Last updated by steveS-12 1 week, 2 days ago.

Assigned support staff: Radu.

Author Posts
September 26, 2019 at 6:19 pm #4649623

steveS-12

I'm using the following PHP to output the French translation URL of the corresponding English page:

apply_filters( 'wpml_permalink', $url , 'fr' )

This works on all pages of my site except for the events calendar pages, i.e.

/events
/evente/event-title

On these pages the code outputs nothing.

You can see this occurring here:
hidden link

September 27, 2019 at 4:52 am #4651713

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Steve,

Thank you for reaching out the WPML support!

I checked this out and it seems that this issue about the Events Calendar slug is already on our list. According to my colleagues tests, this is something that needs to be changed on both WPML and Events Calendar plugin.

I already added this ticket to the issue on our list so I can keep you posted about the progress we're making on this. Also, I will try to come back with an early fix if possible (once we manage to fix this).

Thanks,
Radu

September 27, 2019 at 3:32 pm #4655615

steveS-12

Hi Radu, is there a WPMU function that will provide the corresponding translated post ID that may work with the Events Calendar? If I can just generate the post_id I can do the rest with finding the permalink.

October 1, 2019 at 5:32 am #4668781

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Steve,

I think that you can use this hook to get the ID of the translated event: https://wpml.org/wpml-hook/wpml_object_id/. You can find a bit more details about this right here: https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/#2-manually-using-the-wpml_object_id-function

Thanks,
Radu

October 4, 2019 at 3:13 pm #4696837

steveS-12

Thanks. This is what I ended up using that works but not exactly ideal-

if ($post_type != 'tribe_events') {
	$url = get_the_permalink();
	$url_en = apply_filters( 'wpml_permalink', $url , 'en' );
	$url_fr = apply_filters( 'wpml_permalink', $url , 'fr' );
}

if ($post_type == 'tribe_events') {
	$event_post_id_en = apply_filters( 'wpml_object_id', $post_id, 'tribe_events', FALSE, 'en' );
	$event_post_id_fr = apply_filters( 'wpml_object_id', $post_id, 'tribe_events', FALSE, 'fr' );
	$url_en = '/event/'.get_post($event_post_id_en)->post_name;
	$url_fr = '/fr/event/'.get_post($event_post_id_en)->post_name;
}
if ($_SERVER['REQUEST_URI'] == '/events/' || $_SERVER['REQUEST_URI'] == '/fr/events/') {
	$url_fr = '/fr/events/';
	$url_en = '/events/';
}