Programming, WordPress

WPML custom post type slug translation

If you are struggling to translate the slugs for custom post type then, read this article and try to implement the solution in your website.

Suppose, we have custom post type ‘programs‘ and we want to update its slug for each available languages.

add_action('init', function(){
    register_post_type( 'programs',
        [
            'label' => 'programs',
            'public' => true,
            'rewrite' => [
                'slug' => 'programas'
            ]
        ]
    );

});

I would like to recommend the following steps for translating the custom post type slugs in different languages :

  1. Go to WPML -> String Translation
  2. From the String Translation admin screen search for the English slug “programs”, select the available strings and delete it. Similarly, from the String Translation admin screen search for the slug “programas” and delete it. In short, delete any string translation for related custom slugs.
  3. Go to WPML-> Translation Management-> Multilingual Content Setup and in the Custom posts slug translation options, check the box to “Translate custom posts slugs (via WPML String Translation).” and click Save.
  4. Then, scroll down to custom post types, where you can see the lists for posts ready to to be translated. Select the post to be translated and Save it. Once the page refreshes, you can see the original posts slug  and fields where you can enter the slugs for each of your secondary languages. Save the translated custom post slugs.
  5. Check the posts links for each language.Finally, you can see the fine links with the translated slug for each language.

Visits: 139

Standard