Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

dersime on "Polylang/ Woocommerce product slug base translation"

$
0
0

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 lang

First 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 aswell

Is there any way to achieve my idea?

Sincerely,
Dersime


Viewing all articles
Browse latest Browse all 11471


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>