Custom taxonomies in product url not translated
-
Hi,
I’ve set up a catalog website which contains products sorted under categories and subcategories. The products are a custom post type, the product categories are a custom taxonomy.
When I’m on a product page in EN, the language switcher directs to other languages without translating the category part of the url.
Eg. when I’m on/en/pots/antique-pots/brown-pot
, the language switcher for NL translation links to/nl/pots/pots/antique-pots/bruine-pot
. The product slug is translated, but the category isn’t.This also creates issues for the hreflang setup, which has the same issue.
Is this solveable with the pll_rewrite_rules filter? If so, can someone explain me how? Cause I can’t get it to work.
The rewrite rules for my product urls I’ve set up look like this:
public static function tsrc_public_product_url_structure($post_link, $id = 0) { $post = get_post($id); if ( is_object( $post ) ){ $terms = wp_get_object_terms( $post->ID, 'tsrc_public_category' ); if( $terms ){ $slug = get_term_parents_list($terms[0], 'tsrc_public_category', ['format'=>'slug','link'=>false]); return str_replace( '%tsrc_public_category%/' , $slug , $post_link ); } } return $post_link; }
- This topic was modified 3 years, 8 months ago by .
- This topic was modified 3 years, 8 months ago by .
- This topic was modified 3 years, 8 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘Custom taxonomies in product url not translated’ is closed to new replies.