Skip Navigation

This topic contains 0 reply, has 1 voice.

Last updated by adrienR-5 6 days, 23 hours ago.

Assisted by: Shekhar Bhandari.

Author Posts
June 24, 2025 at 8:52 am #17163675

adrienR-5

Background of the issue:
I am developing a site and have added some query_vars and rewrite_rule to create dynamic pages.

Here's my current code: "function sws_franchise_reviews_custom_query_vars($vars) {
$vars[] = "franchise_slug";
$vars[] = "franchise_reviews_page";
$vars[] = "franchise_review_id";

return $vars;
}
add_filter("query_vars", "sws_franchise_reviews_custom_query_vars");

function sws_franchise_reviews_custom_rewrite_rule() {
add_rewrite_tag("%franchise_name%", "([^/]+)");
add_rewrite_rule(
"^franchise/([^/]+)/avis/?",
'index.php?franchise_name=$matches[1]&post_type=franchise&franchise_reviews_page=1&do_not_redirect=1',
"top"
);
add_rewrite_rule(
"^franchise/([^/]+)/avis/([^/]+)/?",
'index.php?franchise_name=$matches[1]&post_type=franchise&franchise_reviews_page=1&do_not_redirect=1&franchise_review_id=$matches[2]',
"top"
);
}
add_action("init", "sws_franchise_reviews_custom_rewrite_rule", 10, 0);"

This is working well for my default language (FR).

Symptoms:
I need to create similar functionality for different WPML languages.

Questions:
How can I create similar query_vars and rewrite_rule for different WPML languages?

The topic ‘[Closed] Create query_vars and add_rewrite_rule for alternative WPML languages’ is closed to new replies.