Title: permalink manager + wpml + same URI
Last modified: June 15, 2022

---

# permalink manager + wpml + same URI

 *  Resolved [fdetourneint](https://wordpress.org/support/users/fdetourneint/)
 * (@fdetourneint)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/)
 * Hello,
 * I have a problem when I put the same URI for 1 same page in several languages.
   
   I use WPML.
 * For example, for a site in french by default :
    in French: uri = paris.html -
   > domain.com/paris.html in English : uri = paris.html -> domain.com/en/paris.
   html in German : uri = paris.html -> domain.com/de/paris.html
 * But only page in english displayed and the others show a 404 error.
 * When I change for english page to paris-en.html and german page to paris-de.html,
   it works but I want same URI.
 * Do you know what the problem would be?
 * Thank you,
    FD

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/#post-15740412)
 * Hi [@fdetourneint](https://wordpress.org/support/users/fdetourneint/),
 * Could you check if “WPML/Polylang language mismatch” option is turned on in Permalink
   Manager settings?
 * Best regards,
    Maciej
 *  Thread Starter [fdetourneint](https://wordpress.org/support/users/fdetourneint/)
 * (@fdetourneint)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/#post-15742163)
 * Hi Maciej,
 * I had seen this on a Polylang forum but for WPML I couldn’t find it. In fact 
   it was the same setting. It’s working fine now!!
 * Thank you very much !
 * FD
 *  Thread Starter [fdetourneint](https://wordpress.org/support/users/fdetourneint/)
 * (@fdetourneint)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/#post-15742714)
 * Hi Maciej,
 * I have another problem when I turn on “WPML/Polylang language mismatch” option.
   
   For example, I have a page with different language : – in FR : domain.com/la-
   region – in EN : domain.com/en/the-region – in NL : domain.com/nl/de-region
 * When WMPL option turn on, if I test this url : domain.com/en/la-region, I have
   304 http code with html in english but i have no redirection to domain.com/en/
   the-region.
 * How can I have a redirection 301 to domain.com/en/the-region for this example?
 * Thanks,
    FD
 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/#post-15742809)
 * Hi [@fdetourneint](https://wordpress.org/support/users/fdetourneint/),
 * Unfortunately this is not possible with the plugin itself at this moment. However,
   you can try to use the below code snippet to check the language mismatch:
 *     ```
       function pm_fix_language_mismatch($item_id, $uri_parts, $is_term = false) {
       	if(!$is_term) {
       		$element = get_post($item_id);
   
       		if(!empty($element->post_type)) {
       			$element_id = $item_id;
       			$element_type = $element->post_type;
       		}
       	}
   
       	// Stop if no term or post is detected
       	if(empty($element)) { return false; }
   
       	// Get the language code of the found post/term
       	$element_language_code = Permalink_Manager_Language_Plugins::get_language_code($element);
   
       	// Get the detected language code
       	if(defined('ICL_LANGUAGE_CODE')) {
       		$detected_language_code = ICL_LANGUAGE_CODE;
       	} else if(!empty($uri_parts['lang'])) {
       		$detected_language_code = $uri_parts['lang'];
       	} else {
       		return $item_id;
       	}
   
       	if($detected_language_code !== $element_language_code) {
       		$item_id = apply_filters('wpml_object_id', $element_id, $element_type);
   
       		if(!empty($item_id)) {
       			$canonical_permalink = get_permalink($item_id);
   
       			wp_safe_redirect($canonical_permalink, 301);
       			exit();
       		}
       	}
   
       	return $item_id;
       }
       add_filter('permalink_manager_detected_post_id', 'pm_fix_language_mismatch', 7, 3);
       ```
   
 *  Thread Starter [fdetourneint](https://wordpress.org/support/users/fdetourneint/)
 * (@fdetourneint)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/#post-15743683)
 * Hi Maciej,
 * Thank you for your code, it works.
 * FD

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘permalink manager + wpml + same URI’ is closed to new replies.

 * ![](https://ps.w.org/permalink-manager/assets/icon.svg?rev=2625166)
 * [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/permalink-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/permalink-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/permalink-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/permalink-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/permalink-manager/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [fdetourneint](https://wordpress.org/support/users/fdetourneint/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/permalink-manager-wpml-same-uri-2/#post-15743683)
 * Status: resolved