This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to configure the hreflang tags for your multilingual site and need the x-default hreflang tag to be set on the English version instead of the Italian version, which is the default language.
Solution:
We recommend using the wpml_hreflangs filter to adjust the hreflang tags. Here is a proof of concept code:
add_filter( 'wpml_hreflangs', function( $hreflang_items ) { if ( is_array( $hreflang_items ) ) { foreach( $hreflang_items as $hreflang_code => $hreflang_url ) { if( $hreflang_code == 'x-default' ) { $hreflang_items['x-default'] = $hreflang_items['en']; } } } return $hreflang_items; } );
Add this code to the functions.php file of a staging copy of your site and adapt it as needed. If you are not comfortable implementing this, consider contacting one of our certified partners.
For further examples and discussions related to hreflang tags, you can visit these threads:
- Multiple hreflang tags for one language
- X-default tag in our page
- Hreflang x-default is missing from some pages
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket.
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 1 reply, has 2 voices.
Last updated by Nicolas V. 2 months, 3 weeks ago.
Assisted by: Nicolas V..