This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 11.25 hours from now. Thank you for your understanding.

This topic contains 15 replies, has 2 voices.

Last updated by Radu 5 months, 1 week ago.

Assigned support staff: Radu.

Author Posts
April 17, 2019 at 10:06 am

alexandreG-8

Hi, I've some problem with Custom post type that doesn't display in English, and ACF field that cannot be traduce

I am trying to : have a French web site traduce in English

Link to a page where the issue can be seen:
French > hidden link
English > hidden link

I expected to see :
• the custom post traduce
• the footer Baseline and the Alcool mention traduced

Instead, I got :
• a 404 error even if all the custom post slug, the taxonomy and the post are traduced, the URL is OK but nothing is displayed
• Cant traduce the footer Baseline and Alcool mention inthe back office even if there is a French version and en English version, when I try to update it update both (French and English)

--------

I've 2 another questions :
• how to put the French website like that hidden link
• We are in production for the moment and trying to go live at the end of the week, what is the best way to go from hidden link to hidden link

Thanks for you help

April 18, 2019 at 4:57 am #3636105

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Alexandre,

Thank you for reaching out the WPML support!

Do you know if you're using any rewrite rule on your website? I'm asking for this because I checked a few more custom post types (like izarra house) and they are not working either when I'm trying to check the translation. Also, can you try to deactivate all the plugins except for ACF and WPML (and its add-ons), activate a default theme (like Twenty Nineteen), and tell me if this problem is still available, please? This way we can see if this is not a problem caused by one of the plugins you're using, or by the theme.

Thanks,
Radu

April 20, 2019 at 11:16 am #3650183

alexandreG-8

Hi Radu,

Thanks for your reply, the problem come from the theme,
since my first mail i've resolved a few things like
• the footer Baseline and the Alcool mention traduced with string translation.
• and I've traduced my rewriting rules in the back office with string translation (see screenshots)

But still have problems with my custom post, and different result even if everything is done in the same way, for all my custom post because I need to have : hidden link
Here is the rewriting rules present in my function.php and declare with each custom post arguments
---

"rewrite" => array( "slug" => "maison-izarra/%catmaison%", "with_front" => true ),

for this one the translation of the code work well i've got the good URL in english but have a 404 error
french url : hidden link
english url : hidden link
---

"rewrite" => array( "slug" => "notre-pays-basque/%element%", "with_front" => true ),

for this one the translation of the code is done but doesn't work i've got the bad URL in english but the page is OK.
hidden link instead of having
hidden link
---

"rewrite" => array( "slug" => "mixologie/%catcocktails%", "with_front" => true ),

for this one the translation of the code work well i've got the good URL in english but have a 404 error.
french url : hidden link
english url : hidden link
---

"rewrite" => array( "slug" => "fooding/%categorydesserts%", "with_front" => true ),

for this one work well because even if there is a translation the "fooding" is the same in french and english.
french url : hidden link
english url : hidden link
---

April 23, 2019 at 8:27 am #3660563

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Alexandre,

Can you remove all the rewrite rules so we can make sure that all the translations work fine first, please? Once we take care of this, we'll look again for a way of adding a custom post slug.

Thanks,
Radu

April 23, 2019 at 3:34 pm #3665747

alexandreG-8

Hi Radu,

I've erase all my rewriting rules and it's working
Let me know how to make it the right way

REWRITING RULES
domain / custom-post-type / taxonomy / postname

MAISON
What we have now
hidden link
hidden link
What we want
hidden link
hidden link

MIXOLOGIE
What we have now
hidden link
hidden link
What we want
hidden link
hidden link

April 24, 2019 at 9:38 am #3671071

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Alexandre,

I'm glad to hear that everything is back to normal. Now, the WPML plugin does have some options to use custom slugs. All you have to do is go to Dashboard → WPML → Paramètres → Traduction des types de publication and use the Définir différents slugs dans différentes langues pour Maisons Izarra. option.

Also, I can see that the rewrite rule is used for the maison post type. However, the slug is not changed since the simple maison is still used instead of maison-izarra. Can you check this out first, before making the changes in the WPML Settings area, please?

Thanks,
Radu

April 24, 2019 at 10:17 am #3671491

alexandreG-8

Hey Radu,

thanks for you mail, I've delete the last rewriting rule used for maison post type

April 24, 2019 at 10:46 am #3671725

alexandreG-8

I would like to know how to rename my custom post slug, I was using the slug rewriting option in the CPTUI plugin for the moment, because we need to have for exemple maison-izarra and we cannot have a custom post slug with "-"

April 24, 2019 at 12:35 pm #3672765

alexandreG-8

With WPML I can only traduce the French URL version to English but if I erase all the rewriting rules in CPTUI, the French URL are not good and with WPML I can only modify the English URL the French one can't be modify

April 24, 2019 at 5:46 pm #3675651

alexandreG-8

So I've edit all the English URL, they're working but the taxonomy is missing
I NEED
domain / custom-post-type / taxonomy / postname

I HAVE
domain/custom-post-type/postname

And I can't EDIT French URL the unique way to modify, it's to go to CPT UI and modify the custom rewrite slug, like I've done it before…

Permalink are like that > domain/%category%/%postname%/

April 25, 2019 at 9:47 am #3680707

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Alexandre,

Let's try to do the following change to cocktails.

First, please add back the rewrite rule:

"rewrite" => array( "slug" => "mixologie/%catcocktails%", "with_front" => true),

Once you've done this, just go to Dashboard → WPML → Settings → Post Types Translation and check again the options to translate the slug. Now, mixologie/%catcocktails% should be displayed for the original language and you should be able to add the translation for the other languages.

Can you give this a try and tell me how it goes, please?

Thanks,
Radu

April 25, 2019 at 10:47 am #3681317

alexandreG-8

Hi Radu,

I've done what you say, but to make it works I've to add this in the function PHP for each taxonomy

function wpa_cocktail_permalinks( $post_link, $post ){
    if ( is_object( $post ) && $post->post_type == 'cocktails' ){
        $terms = wp_get_object_terms( $post->ID, 'catcocktails' );
        if( $terms ){
            return str_replace( '%catcocktails%' , $terms[0]->slug , $post_link );
        }
    }
    return $post_link;
}
add_filter( 'post_type_link', 'wpa_cocktail_permalinks', 1, 2 );

Everything look good in the back office, url slug translation
But when we go on the front office
it works in French
hidden link
but not in English
hidden link

The only custom post that works is fooding because it's the same in French and English
french : hidden link
english : hidden link

April 26, 2019 at 4:22 pm #3692281

alexandreG-8

Hi Radu,

I've no news from you.
I think I'm not the only one with this problem, do someone of the WPML team have a solution for that ? It could help a lot of people.
Thanks for your answer

Have a good week-end

May 2, 2019 at 6:28 am #3722081

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Alexandre,

Sorry for this delayed response. In the last few days I was trying over and over again to understand why is this not working as expected. Just by adding that rewrite rule and translate mixologie/%catcocktails% should be enough. Can you tell me why do you add that filter, please? Last but not least, can you tell me how these custom post types are created? Are you just adding the code to the function.php file? I'll keep looking on this in the meantime and give you another message if I find anything else.

Thanks,
Radu

May 6, 2019 at 8:37 am #3745927

alexandreG-8

Hi Radu,

My custom post type are created at the beginning with CPTUI, but I add it to the function.php and deactivate CPTUI.

I'need that filter because I want to have in the URL
my domain> my custom post > my custom post categories > my post name
and that the only way I find to do it well

Let me know if you find a better way to do it and to make it work in both languages

The topic ‘[Closed] Custom post type with translated slug > error 404 even if all is translated’ is closed to new replies.