This thread is resolved. Here is a description of the problem and solution.
Problem:
The site is using the Header Footer Code Manager to load a snippet with a noindex tag into the head of the source code for specific pages. They are trying to ensure that the translated pages on your site have the same noindex tag as the original pages. The noindex tag is present in the original page's code, but it is missing in the translated versions.
Solution:
To include the noindex tag in the translated pages using WPML, you need to modify the code in the header-footer-code-manager plugin. Follow these steps:
1. Open the
.../wp-content/plugins/header-footer-code-manager/99robots-header-footer-code-manager.php
file.
2. Locate line 550.
3. Open the .../wp-content/plugins/header-footer-code-manager/99robots-header-footer-code-manager.php file
Look for line 550
Replace:
case 's_pages': $is_not_empty_s_pages = self::hfcm_not_empty( $scriptdata, 's_pages' ); if ( $is_not_empty_s_pages ) { // Gets the page ID of the blog page $blog_page = get_option( 'page_for_posts' ); // Checks if the blog page is present in the array of selected pages if ( in_array( $blog_page, json_decode( $scriptdata->s_pages ) ) ) { if ( is_page( json_decode( $scriptdata->s_pages ) ) || (!is_front_page() && is_home()) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } elseif ( is_page( json_decode( $scriptdata->s_pages ) ) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } break;
With:
case 's_pages': $is_not_empty_s_pages = self::hfcm_not_empty( $scriptdata, 's_pages' ); if ( $is_not_empty_s_pages ) { // WPML workaround for compsupp-7802 $original_ids = json_decode( $scriptdata->s_pages); foreach ( $original_ids as $original_id ) { $translated_ids[] = apply_filters( 'wpml_object_id', $original_id, 'page'); } // Gets the page ID of the blog page $blog_page = get_option( 'page_for_posts' ); // Checks if the blog page is present in the array of selected pages if ( in_array( $blog_page, json_decode( $scriptdata->s_pages ) ) ) { if ( is_page( $translated_ids ) || (!is_front_page() && is_home()) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } elseif ( is_page( $translated_ids ) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } break;
This modification ensures that the noindex tag is applied to translated pages as well. If this solution does not resolve your issue or seems outdated, please check the related known issues and confirm that you have installed the latest versions of themes and plugins. If necessary, do not hesitate to 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 16 replies, has 1 voice.
Last updated by 5 months, 4 weeks ago.
Assisted by: Andreas W..