Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //redirect if the language mismatch in URL is detected
- function pm_lang_mismatch_redirect() {
- global $permalink_manager_uris, $pm_query, $wp_query;
- if(!empty($pm_query['id'])) {
- $element_id = (is_singular()) ? $pm_query['id'] : "tax-{$pm_query['id']}";
- $element_uri = $permalink_manager_uris[$element_id];
- $request_uri = $pm_query['uri'];
- if($element_uri !== $request_uri) {
- $wp_query->query_vars['do_not_redirect'] = 0;
- }
- }
- }
- add_action('template_redirect', 'pm_lang_mismatch_redirect', 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement