I want to ask you, how can I set fixed permalink for multilanguage product categories.

Website: https://www.usb-4-logo.com/cs/

In CZECH language I have: kategorie-produktu/usb-flash-disky/

In ENGLISH language I have: product-category/usb-flash-drives/

But the ENGLISH URL version not working, so I must set kategorie-produktu/usb-flash-drives/ as a fixed. Because this type URL working for ENGLISH version. Interesting, but it works.

I remember, that in one old website I used custom rewrite basic function:

function custom_rewrite_basic() {
  $args = array("post_type" => "bunch_property","posts_per_page" => -1);
  $posts = get_posts( $args );
      foreach($posts as $post){
        $cat = get_the_terms($post,"property_category");
        $cat_slug = $cat[0]->slug;
        $post_slug = $post->post_name;
        //echo $cat_slug." ".$post_slug."***";
        add_rewrite_rule('^sk/'.$cat_slug.'/'.$post_slug.'?/', 'index.php/sk/property/'.$cat_slug.'/'.$post_slug.'/', 'top');
        add_rewrite_rule('^en/'.$cat_slug.'/'.$post_slug.'?/', 'index.php/en/property/'.$cat_slug.'/'.$post_slug.'/', 'top');
      } 
      global $wp_rewrite;   
      //print_r( $wp_rewrite);
      //add_rewrite_rule('^'.'prenajom-skladovych-priestorov/oblukovy-sklad'.'?/', 'index.php/property/'.'prenajom-skladovych-priestorov/oblukovy-sklad'.'/', 'top');
}
add_action('init', 'custom_rewrite_basic');

But I dont know how to use it on a product category in woocommerce.

Thanks for help!

Read more here: Polylang URL – how to use custom rewrite function


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: