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 3 voices.
Last updated by epa-villa-arsonE 4 years, 8 months ago.
Assisted by: Bobby.
Author | Posts |
---|---|
March 20, 2020 at 9:46 pm #5730861 | |
gulshanK |
Tell us what you are trying to do? Is there any documentation that you are following? Is there a similar example that we can see? |
March 20, 2020 at 11:12 pm #5730951 | |
Bobby Supporter
Languages: English (English ) Timezone: America/Los_Angeles (GMT-08:00) |
Hi There, 1. Please verify that your page has been 100% translated, once it is then the hreflang will populate 2. Go to WPML->languages->SEO Options-> Display alternative languages in the HEAD section -> "As Early as possible" Let me know your results, please. |
March 21, 2020 at 9:45 am #5732501 | |
gulshanK |
Hello! 1. Done, I tested again at fresh WordPress. Ref: [removed] Thanks |
March 21, 2020 at 7:04 pm #5733913 | |
Bobby Supporter
Languages: English (English ) Timezone: America/Los_Angeles (GMT-08:00) |
I would like to request temporary access (wp-admin and FTP) to your site to test the issue. **Before we proceed I recommend taking FULL BACKUP of your database and your website.** You will find the needed fields for this below the comment area when you log in to leave your next reply. NOTE: If access to the live site is not possible and the staging site does not exist please provide me with a duplicator package created with the duplicator plugin. Thank you, |
March 23, 2020 at 4:51 pm #5743889 | |
Bobby Supporter
Languages: English (English ) Timezone: America/Los_Angeles (GMT-08:00) |
Thank you for the access details! I have removed your debug information from your previous reply. Please review the following URL's source code and notice the hreflang is showing as expected for both languages. The reason you are not seeing it on your homepage is that it is the WordPress archive, the blog posts are being shown on your homepage but not assigned to an existing page, therefore it is expected for 'hreflang' to not show. This is the way WordPress works and is not a bug with WPML, even without WPML you wouldn't see the hreflang in the archive. If you instead create a page called "Blog", translate it and then go to WP->Reading->Assign a static page for homepage and a page for the blog then the hreflangs will show. |
March 23, 2020 at 5:52 pm #5744335 | |
gulshanK |
Hi again! Please remove mentioned URL and screenshot. That's not required. I understood. I did not received solution as expected what I feel a plugin should do instead expressing technical limitation, disappointed. Anways, Thanks for trying to help me. Here's an alternative solution that I discovered. Thanks to dev Tom's theme: GeneratePress - Elements plugin, allow me to manually written hreflang code just for the Homepage as page rule. Thanks |
March 23, 2020 at 6:21 pm #5744509 | |
Bobby Supporter
Languages: English (English ) Timezone: America/Los_Angeles (GMT-08:00) |
The screenshot and URL has been removed. Please note that this is a WordPress limitation and not a WPML one. Thank you for sharing your solution as this could help other users that might experience this. |
January 10, 2021 at 7:59 pm #7810899 | |
epa-villa-arsonE |
For People passing by and facing the same issue, here is a piece of code you can put in your functions.php theme file to add hreflang tags on blog page : /** * Add Hreflang Link on Blog Page * @hooks on wp_head * @return string * Author : Afterglow Web Agency */ function afg_hreflangOnBlog() { if(!function_exists('icl_get_languages')) return; if(is_home()) { $defaultLanguage = apply_filters('wpml_default_language', NULL ); $siteLanguages = icl_get_languages('skip_missing=1&orderby=code'); foreach ($siteLanguages as $l) { $code = $l['language_code']; echo $code != $defaultLanguage ? '<link rel="alternate" hreflang="'.$code.'" href="'.get_post_type_archive_link( 'post' ).'/'.$code.'/">' : '<link rel="alternate" hreflang="'.$code.'" href="'.get_post_type_archive_link( 'post' ).'">'; } } } add_Action( 'wp_head', 'afg_hreflangOnBlog'); This code will automatically populate all the hreflang tags on default WordPress blog page. Regardless it is the front page or an inner page. |