WordPress-Post-Type-Archive-Links icon indicating copy to clipboard operation
WordPress-Post-Type-Archive-Links copied to clipboard

Gets not translated slug from WPML

Open abombelli opened this issue 10 years ago • 5 comments

When using WPML to translate the CPT slug, the according language is not reflected in the permalink when inserting an archive menu entry.

abombelli avatar May 13 '14 07:05 abombelli

@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

gmazzap avatar May 13 '14 10:05 gmazzap

@Giuseppe-Mazzapica I updated the plugin, unfortunately the slug is still the wrong one. Any other idea?

abombelli avatar May 15 '14 13:05 abombelli

@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.

gmazzap avatar May 15 '14 19:05 gmazzap

@Giuseppe-Mazzapica Just tried your fork, but the slug is still not the translated one who appears.

abombelli avatar May 20 '14 07:05 abombelli

@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.

abombelli avatar May 22 '14 12:05 abombelli