This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing an issue where the
[rank_math_html_sitemap]
shortcode is displaying all pages, including those in the original and translated languages, we have a solution for you.
Solution:
1. Open the
.../wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/html-sitemap/class-posts.php
file.
2. Locate the SQL query around line 88.
3. Replace the existing SQL query with the following code, which includes a filter for the current language:
$current_language = apply_filters( 'wpml_current_language', NULL ); <br /> $sql = "<br /> SELECT l.ID, post_title, post_name, post_parent, post_date, post_type, l.post_modified<br /> FROM (<br /> SELECT DISTINCT p.ID, p.post_modified FROM {$wpdb->posts} as p<br /> LEFT JOIN {$wpdb->postmeta} AS pm ON ( p.ID = pm.post_id AND pm.meta_key = 'rank_math_robots' )<br /> INNER JOIN {$wpdb->prefix}icl_translations AS icl ON ( p.ID = icl.element_id AND icl.language_code = %s AND icl.element_type LIKE 'post_%' )<br /> WHERE (<br /> ( pm.meta_key = 'rank_math_robots' AND pm.meta_value NOT LIKE '%noindex%' ) OR<br /> pm.post_id IS NULL<br /> )<br /> AND p.post_type IN ( %s ) AND p.post_status IN ( '" . join( "', '", esc_sql( $statuses ) ) . "' )<br /> ORDER BY p.post_modified DESC<br /> ) o<br /> JOIN {$wpdb->posts} l ON l.ID = o.ID " . $get_child . " ORDER BY " . $sort['field'] . " " . $sort['order']; // phpcs:ignore<br /> $sql = $wpdb->prepare($sql, $current_language, $post_type);<br /> return $wpdb->get_results( $sql ); // phpcs:ignore
4. Remember that Rank Math uses cache, so you may need to reset your sitemaps after making this change. To do this, go to Rank Math SEO > Sitemaps settings, modify a setting, revert the change, and save it.
Please note that this solution might be outdated or not applicable to your case. If it doesn't help, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket with us.
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.
Our next available supporter will start replying to tickets in about 5.62 hours from now. Thank you for your understanding.
This topic contains 8 replies, has 2 voices.
Last updated by Christopher Amirian 3 months ago.
Assisted by: Christopher Amirian.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.