Skip Navigation

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

Last updated by Izzi Hassan 11 months ago.

Assigned support staff: Izzi Hassan.

Author Posts
July 13, 2020 at 4:18 pm

jonathanF-3

When viewing English page source, both hreflang URLs have the string "blog" in the slug. When you view page source from French page, both show the string "blogue". Client expects that fr-CA shows blogue and en shows blog on either page source hreflang.

July 13, 2020 at 6:50 pm
July 15, 2020 at 5:31 am #6599191

Izzi Hassan

Hi,

Thank you for reaching out to WPML Support.

I installed "File Manager" on your website so that I could take a look at the child theme files.

In your wp-content/themes/jupiterx-child/functions.php file, the following code is handling the rewrite to "blogue":

/* Règle de récriture blog pour FR et EN */
add_filter('rewrite_rules_array', 'rewrite_rules_blog');
function rewrite_rules_blog($rules) {
    	$newRules  = array();

		$newRules['^blogue/([^/]+)/?'] = 'index.php?name=$matches[1]&lang=fr';
		$newRules['^blog/([^/]+)/?'] = 'index.php?name=$matches[1]&lang=en';
		/*echo '<pre>';
		var_dump($rules);
		echo '</pre>';*/
    return array_merge($newRules, $rules);
}

This is using the following WP function:
https://developer.wordpress.org/reference/hooks/rewrite_rules_array/

Unfortunately, WPML does not currently have a way to translate custom permalink structures. This has caused compatibility issues with other plugins in the past and is not supported.

Our recommendation, to achieve the URL structure you currently have, is to use a custom post type instead of the default WP "Post". This gives you far great control over the settings, including the base slug for that custom post type.

https://wpml.org/documentation/getting-started-guide/translating-custom-posts/
---------

Since your website is live and has content, I would recommend asking the developer that added the function above to also rewrite hreflang when rewriting the URL.

I hope this is helpful!

Stay Safe!

July 15, 2020 at 5:32 am #6599195

Izzi Hassan

Here is some information on translating Page Slugs, including slugs for Custom Post Types:
https://wpml.org/documentation/getting-started-guide/translating-page-slugs/