Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

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.

This topic contains 3 replies, has 4 voices.

Last updated by capie 2 years, 4 months ago.

Assigned support staff: Bernat Torras.

Author Posts
March 21, 2017 at 5:33 pm #1236091

lucaP-26

I created a custom post type called "product" through the CPT UI plugin.

This custom post type has also a custom taxonomy called "tipology" (through the CPT UI plugin).

My goal was to have the URL of my product like:

<em><u>hidden link</u></em>

So I set up the "Custom rewrite slug" of my custom post type "product" like

catalog/%tipology%

%tipology% is showing the relative taxonomy of the product, for example:

<em><u>hidden link</u></em>

To do this rewrite, I wrote this code inside the function.php

add_filter( 'post_type_link', 'product_type_link', 1, 3 );
function product_type_link( $post_link, $id = 0 ){
    $post = get_post( $id );
    $post_type = 'product';
    $taxonomy = 'tipology';
    if( !is_object( $post ) || $post->post_type != $post_type )
        return $post_link;
    if( $terms = wp_get_object_terms( $post->ID, $taxonomy ) )
        $slug = $terms[0]->slug;
    $post_link = str_replace( '%'. $taxonomy .'%', $slug, $post_link );
    return $post_link;
} 

This filter works well.
Then:
- I have activated WPML with 6 languages
- I'm going to WPML -> Translation managment -> Custom post, I have activated the option "User different slug for the different languages in product".

I see correctly the slug "catalog/%tipology%". Inside the fields I have typed in the relative translation, for example:
IT -> "catalogo/%tipology%"
FR -> "catalogue/%tipology%"
On the wp-admin I see that the permalink is rewriting correctly but when I see the frontend I have the 404 error.
I have already saved again the permalink...
I have already translated the string "catalog/%tipology%" inside WPML->Translation string but it doesn't work... 404 error...

Do you have any idea?

Thanks

March 22, 2017 at 12:30 pm #1236755

Bernat Torras

Hi @lucap-26,

Thanks for contacting support, I'll do my best to help you with this! 🙂

To tell you the truth I'm not sure about this behaviour. I understand how are you modifying the product permalinks but I'm not quite sure about the consequences and implications that could affect WPML.

Just to test, have you tried if the result is the same without translating the CPT slug?

In any case, I think that this issue will imply a deeper debugging, so, could you please provide us the following?

1- Complete backup of your site: I'd suggest you to install and use 'Duplicator' plugin to generate the backup (package) of your site (you can exclude uploads folder to reduce the size).

2- Backend/ftp credentials: I'll enable you a private form on your next reply where you'll be able to share us your backend and ftp credentials with us in a private and secure way. Please fill all required fields to let us take a deeper look at your site configuration and files.

Once we have the backup ready and the credentials we'll log on your backend and download the backup directly from there and use it to replicate and debug your issue on our private local servers.

Thanks
Bernat

May 12, 2017 at 7:33 am #1274466

nikolaosG-2

I face exactly the same problem.
I have spent two days where the problem might be.
Did you find any solution to this?

September 6, 2017 at 5:24 pm #1362347

capie

Is there any update on this? I have also the same problem.
Thanks!

The topic ‘[Closed] Translation of a custom rewrite slug of a custom post type’ is closed to new replies.