- Stato
- Risolto
- Segnalato per
- WPML SEO 2.1.0
- Risolto in
- 2.2.0
- Plugin/tema correlato
- Rank Math SEO
- Tag dell’argomento
- Compatibility
Panoramica del problema
Lo shortcode rank_math_html_sitemap fornito dal plugin Rank Math SEO mostra una sitemap HTML che include le pagine di tutte le lingue, invece di mostrare i contenuti solo nella lingua corrente.
Soluzione alternativa
Assicurati di avere un backup completo del tuo sito prima di procedere.
- Apri il file …/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/html-sitemap/class-posts.php.
- Cerca la riga 88.
- Cambia:
$sql = " SELECT l.ID, post_title, post_name, post_parent, post_date, post_type, l.post_modified FROM ( SELECT DISTINCT p.ID, p.post_modified FROM {$wpdb->posts} as p LEFT JOIN {$wpdb->postmeta} AS pm ON ( p.ID = pm.post_id AND pm.meta_key = 'rank_math_robots' ) WHERE ( ( pm.meta_key = 'rank_math_robots' AND pm.meta_value NOT LIKE '%noindex%' ) OR pm.post_id IS NULL ) AND p.post_type IN ( '" . $post_type . "' ) AND p.post_status IN ( '" . join( "', '", esc_sql( $statuses ) ) . "' ) ORDER BY p.post_modified DESC ) o JOIN {$wpdb->posts} l ON l.ID = o.ID " . $get_child . " ORDER BY " . $sort['field'] . " " . $sort['order']; // phpcs:ignore return $wpdb->get_results( $wpdb->prepare( $sql ) ); // phpcs:ignore - Con:
$current_language = apply_filters( 'wpml_current_language', NULL ); $sql = " SELECT l.ID, post_title, post_name, post_parent, post_date, post_type, l.post_modified FROM ( SELECT DISTINCT p.ID, p.post_modified FROM {$wpdb->posts} as p LEFT JOIN {$wpdb->postmeta} AS pm ON ( p.ID = pm.post_id AND pm.meta_key = 'rank_math_robots' ) 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_%' ) WHERE ( ( pm.meta_key = 'rank_math_robots' AND pm.meta_value NOT LIKE '%noindex%' ) OR pm.post_id IS NULL ) AND p.post_type IN ( %s ) AND p.post_status IN ( '" . join( "', '", esc_sql( $statuses ) ) . "' ) ORDER BY p.post_modified DESC ) o JOIN {$wpdb->posts} l ON l.ID = o.ID " . $get_child . " ORDER BY " . $sort['field'] . " " . $sort['order']; // phpcs:ignore $sql = $wpdb->prepare($sql, $current_language, $post_type); return $wpdb->get_results( $sql ); // phpcs:ignore
Tieni presente che potresti dover reimpostare le tue sitemap. Puoi farlo andando su Rank Math SEO > Impostazioni della sitemap, modificando un’impostazione e cambiandola di nuovo.