[Resolved] Translate custom post type slug rewrite
This thread is resolved. Here is a description of the problem and solution.
Problem:
I'm using this method https://wisdmlabs.com/blog/add-taxonomy-term-custom-post-permalinks-wordpress/ to create a CPT, my custom taxonomy and a rewrite rule to add taxonomy terms to my permalink structure. I'm trying to translate my Custom post type slug using WPML. I have already translated the content of the slug using WPML, but I have got a 404 error.
Solution:
This would require some custom rewrite rules via "add_rewrite_rule".
Im' trying to translate my Custom post type slug using WPML.
I have already translate the content of the slug using WPML see attached but i have a 404 error.
French version (default language) : hidden link
English version : hidden link
Can you tell me if this is happening if you try to change the slug of a different post type maybe? What if you set with_front to true?
Also, can you go to WPML → String translation, search for the slug, and make sure that the translation is set as Translation is complete, please?
Last but not least, have you tried to flush the permalinks by going to Settings → Permalinks and just hit the Save Changes button? This is doing the trick most of the time when you get a 404 error.
Can you try to use a permalink without a taxonomy on it and tell me if you can translate it this way, please?
Also, it would be great if you could create the same custom post type and taxonomy here, on a clean website: hidden link
You can add the code to the functions.php file of the Twenty Twenty theme. I just want to see if we can replicate this issue on a clean website so I can pass this to my colleagues for a closer look.
• To answer your first questions, if i try to translate the permalink without the taxonomy inside, that's work :
EN : hidden link
FR : hidden link
• I add exactly the same CPT and Taxo on your website with two test :
- The first one with just WPML Multilingual CMS activated. And with this solution, the permalink with the taxonomy works well but i can't translate the part before the taxonomy.
EN : hidden link
FR : hidden link
- The second one including WPML String Translation activated to have the capability to translate the first part of the permalink , but that doesn't work :
EN : Error 404 : hidden link
FR : hidden link
I checked this out and look for other tickets about the same topic, but I couldn't find a fix for this. I asked my colleagues to have a look at this in order to see if there's anything I'm missing out.
I'll come back here as soon as one of my colleagues is having a look at this (which it shouldn't take long).