Skip Navigation

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 7 replies, has 2 voices.

Last updated by Bigul 5 years ago.

Assigned support staff: Bigul.

Author Posts
January 18, 2017 at 2:57 pm #1185079

Gianluigi

Hello
I am trying to enable the hreflang SEO option. It's works fine in pages and posts but doesn't in custom post type where I activeted a plugin for custom permalink (https://wordpress.org/plugins/remove-slug-from-custom-post-type/).

If I view this page hidden link I expected to see:

<link rel="alternate" hreflang="en-US" href="hidden link" />
<link rel="alternate" hreflang="it-IT" href="hidden link" />
<link rel="alternate" hreflang="ru-RU" href="hidden link" />
<link rel="alternate" hreflang="fr-FR" href="hidden link" />

Instead, I got:

<link rel="alternate" hreflang="en-US" href="hidden link" />
<link rel="alternate" hreflang="it-IT" href="hidden link" />
<link rel="alternate" hreflang="ru-RU" href="hidden link" />
<link rel="alternate" hreflang="fr-FR" href="hidden link" />

Thank you

January 19, 2017 at 7:57 am #1185606

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi ,

Thank you for contacting the WPML support. We are happy to help you.

May it will be happening because you are using an older version of WPML, WordPress and Yoast SEO. The current version of WPML is 3.6.2.

I have a request; please try to replicate the issue in a testing environment with the latest version of WPML, WordPress and Yoast SEO. If the issue is existing please let me know the exact steps to reproduce the issue. Hope the custom post type will be a part of your theme.

--
With Regards

Bigul

January 19, 2017 at 2:14 pm #1186059

Gianluigi

Hi,
the problem persits after the update. You should create a custom post type and activate the plugin. After that navigate to the sigular page with the hreflang SEO option enalbled.

Thank you

January 20, 2017 at 6:03 am #1186600

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi ,

Thank you for the updates. I can replicate the issue locally. It is happening because https://wordpress.org/plugins/remove-slug-from-custom-post-type/ is not compatible with WPML. Also, it is an old plugin without support. Therefore we have limitations to make it compatible.

As a workaround, please try solution recommends in this article. It is working fine for me in my local. Please try after a full site backup and let me know your feedback.

hidden link

--
With Regards

Bigul

2017-01-20_1135.png
2017-01-20_1138.png
2017-01-20_1139.png
January 20, 2017 at 5:11 pm #1187299

Gianluigi

Thank you.
Now the hreflang in the single page works.
There is a new problem in taxonomy archive. When I set the slug in the custom taxonomy with

'slug'	 => __( 'name-custom', 'text-domain' )

the hreflang doesn't replace the string with the relative translation.

I expected to see:

<link rel="alternate" hreflang="en-US" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="it-IT" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="ru-RU" href="<em><u>hidden link</u></em>" />

Instead, I got:

<link rel="alternate" hreflang="en-US" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="it-IT" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="ru-RU" href="<em><u>hidden link</u></em>" />

Thank you

January 23, 2017 at 7:30 am #1187941

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Please explain little more about the issue. Hope you have translated the slugs to the secondary language. If possible please share the code you are using.

--
With Regards

Bigul

January 23, 2017 at 9:14 am #1188029

Gianluigi

Hi,
below the code:

function ground_register_catalog_taxonomy()  {

    $labels = array(
        'name'                          => _x( 'Categories', 'Taxonomy General Name', 'ground-admin' ),
        'singular_name'                 => _x( 'Category', 'Taxonomy Singular Name', 'ground-admin' ),
        'menu_name'                     => __( 'Categories', 'ground-admin' ),
        'all_items'                     => __( 'All Categories', 'ground-admin' ),
        'parent_item'                   => __( 'Parent category', 'ground-admin' ),
        'parent_item_colon'             => __( 'Parent category:', 'ground-admin' ),
        'new_item_name'                 => __( 'New category name', 'ground-admin' ),
        'add_new_item'                  => __( 'Add new category', 'ground-admin' ),
        'edit_item'                     => __( 'Edit category', 'ground-admin' ),
        'update_item'                   => __( 'Update category', 'ground-admin' ),
        'separate_items_with_commas'    => __( 'Separate Categories with commas', 'ground-admin' ),
        'search_items'                  => __( 'Search Categories', 'ground-admin' ),
        'add_or_remove_items'           => __( 'Add or remove Categories', 'ground-admin' ),
        'choose_from_most_used'         => __( 'Choose from the most used Categories', 'ground-admin' ),
    );

    $rewrite = array(
        'slug'                          => __( 'catalog-category', 'ground-admin' ),
        'with_front'                    => true,
        'hierarchical'                  => true
    );

    $args = array(
        'labels'                        => $labels,
        'hierarchical'                  => true,
        'public'                        => true,
        'show_ui'                       => true,
        'show_admin_column'             => true,
        'show_in_nav_menus'             => true,
        'show_tagcloud'                 => false,
        'rewrite'                       => $rewrite
    );

    register_taxonomy( 'ground_catalog_taxonomy', 'ground_catalog', $args );

}

add_action( 'init', 'ground_register_catalog_taxonomy', 0 );

The problem is on this line:

'slug'                          => __( 'catalog-category', 'ground-admin' ),

This string is translated in all languages.
In all the links "catalog-category" is translated only in the active language.

If I viewing the site in "en-US" I get this:

<link rel="alternate" hreflang="en-US" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="it-IT" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="ru-RU" href="<em><u>hidden link</u></em>" />

If I viewing the site in "it-IT" I get this:

<link rel="alternate" hreflang="en-US" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="it-IT" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="ru-RU" href="<em><u>hidden link</u></em>" />

If I viewing the site in "ru-RU" I get this:

<link rel="alternate" hreflang="en-US" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="it-IT" href="<em><u>hidden link</u></em>" />
<link rel="alternate" hreflang="ru-RU" href="<em><u>hidden link</u></em>" />

Thank you

January 23, 2017 at 2:46 pm #1188432

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Sorry to inform you that, it is not possible. Becuase there are some limitations for the translation of taxonomy slug from WordPress itself. Now we can only translate the taxonomy term.

But we will surely consider it as a feature request.

--
With Regards

Bigul