I did it in the past and it did work. But this time it won't work and I can't figure out why. The difference is the version of Wordpress and the version of WPML.

So, I have the latest version of both:

WP : Version 4.7.3
WPML : Version 3.6.3

My .htaccess is:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

And my function PHP contain this code:

function custom_rewrite_rule()
    add_rewrite_rule('^nos-ecoles/ecole/(.+?)/?', 'index.php?page_id=153&school=$matches[1]&lang=fr', 'top');
    add_rewrite_rule('^our-schools/school/(.+?)/?', 'index.php?page_id=151&school=$matches[1]&lang=en', 'top');
add_action('init', 'custom_rewrite_rule', 10, 0);

function custom_rewrite_tag() {
    add_rewrite_tag('%school%', '([^&]+)');
add_action('init', 'custom_rewrite_tag', 10, 0);

Note that the page ID in both case are good. English and French are OK, I did validate it.

Problem is when I access the page like the following exemple (chinatown is the school param), it remove the param and keep the page only:

But when I try to access the page like the following exemple, it works and the param stay in place:

Note that each time I change my function.php, I save my Permalink Settings to reset it.

Any idea how to make it works?????

  • Hi Jean-Francois. Did you find a solution to this? Struggling with the same thing. – Tholle Sep 11 '17 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.