Polylang/ Woocommerce product slug base translation
-
Hello, is it possible to have different shop base url for every language i set?
ex: xxx.site.com/shop/[product_name] -> default language
xxx.site.com/fr/store/[product_name] -> fr langFirst of all, in Permalink options, I can set only static string, like shop or store (/shop/%product_cat%).
So i came up with an idea to add custom tag (%shoppage%).
Now permalink setting looks like (/%shoppage%/%product_cat&)Here’s the code
function create_tags($permalink, $post) { if ( $post->post_type == 'product' ){ if (function_exists('pll_get_post')) { $shoppage = pll__('shop'); } else { $shoppage = 'shop'; } $find = '%shoppage%'; $replace = $shoppage; $permalink = str_replace( $find, $replace, $permalink ); } return $permalink; } add_filter( 'post_type_link', 'create_tags', 6, 2 );
of course it did the job with replacing %shoppage% to translated string, but still that string is not recognized in register_post_type (from woocommerce), and it end with 404 error page. (rewrite rules are not working)
add_rewrite_tag
wont work aswellIs there any way to achieve my idea?
Sincerely,
Dersime
- The topic ‘Polylang/ Woocommerce product slug base translation’ is closed to new replies.