WordPress-Post-Type-Archive-Links
WordPress-Post-Type-Archive-Links copied to clipboard
Gets not translated slug from WPML
When using WPML to translate the CPT slug, the according language is not reflected in the permalink when inserting an archive menu entry.
@stephenharris I think this issue is not only related to WPML, because the menu item printing ignore the CPT labels (and so any associated translation). That can be easily solved replacing menu item title with the CPT object label. Already created a branch with that fix, see here
@Giuseppe-Mazzapica I updated the plugin, unfortunately the slug is still the wrong one. Any other idea?
@abombelli the plugin is not updated using my code, so even if you update the plugin from this repo (or from wordpress.org) it is unchanged. You can try to use the Issue#27 brance on my fork or wait for when Stephen have time to look at it and maybe can merge.
@Giuseppe-Mazzapica Just tried your fork, but the slug is still not the translated one who appears.
@Giuseppe-Mazzapica Not completely tested, but it works. I added the following after line 381:
// WPML - get translated CPT slug
if ( function_exists( 'icl_translate' ) ) {
$translated_slug = icl_translate('wpml_custom', 'wpml_custom_'.$post_type, $post_type);
if ($translated_slug != '') {
$menu_item->url = home_url( user_trailingslashit( $translated_slug, 'post_type_archive' ) );
}
}
The slug has to be translated before.