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

Last updated by sergeyS-14 3 years, 5 months ago.

Assigned support staff: Yuri.

Author Posts
April 11, 2018 at 3:59 pm #1598761


I have custom type and custom taxonomies (property_area, property_city, property_type )

So i extend the existent rewrite rules to get posts by additional rules:

add_filter( 'rewrite_rules_array', 'property_type_add_rewrite_rules' );

function property_type_add_rewrite_rules( $wp_rewrite ) {

$new = array();

$new['property-type/([^/]+)/([^/]+)/(.+)/?$'] = 'index.php?property_type=$matches[1]&property_city=$matches[2]&property_area=$matches[3]';
$new['property-type/([^/]+)/(.+)/?$'] = 'index.php?property_type=$matches[1]&property_city=$matches[2]';
$new['property-type/(.+)/?$'] = 'index.php?property_type=$matches[1]';

return array_merge( $new, $wp_rewrite ); // Ensure our rules come first



Old url was:
hidden link

After i add city or/and area its look like this:
hidden link

So in menu the Language Switcher still have old links, and i wold like to modify his links to

How i can do this? Or may be there is another way (if this one is not correct) to get this links of Language Switcher modified?

April 12, 2018 at 12:53 am #1603015


Hi, you can use the filter "wpml_ls_language_url" that will rewrite the URL used on the Language switcher and manipulate it that way. You can see it being called on the file /wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-model-build.php @ line 115

Let me know if this is what you were looking for.

April 23, 2018 at 4:52 pm #1773951


Great seem like this is it! I Will try soon and change the question to resolved.

Another similar, may be the same answer, question (let me know if need to create separate ticket):

We have configured WPML as different domain for language.
How the WPML do the redirect between domains?
There is some filter or hook we can use to check and redirect if needed?

I am asking because we planing to change the names in url structure so i need to cactch this some how trough hooks or filter i believe.

Thank you!

April 26, 2018 at 4:44 pm #1840929


Thank you this is it.

June 12, 2018 at 1:41 pm #2408434


One more thing, is this possible to get same as the filter "wpml_ls_language_url" but for all languages? Because i can see only current one...