- Trạng thái
- Đã giải quyết
- Được báo cáo cho
- WPML SEO 2.1.0
- Đã giải quyết trong
- 2.2.0
- Plugin/giao diện liên quan
- Rank Math SEO
- Thẻ chủ đề
- Compatibility
Tổng quan về lỗi
Shortcode rank_math_html_sitemap do plugin Rank Math SEO cung cấp đang hiển thị một sitemap HTML bao gồm các trang từ tất cả ngôn ngữ, thay vì chỉ hiển thị nội dung trong ngôn ngữ hiện tại.
Giải pháp tạm thời
Vui lòng đảm bảo tạo một bản sao lưu đầy đủ cho trang web của bạn trước khi tiến hành.
- Mở tệp …/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/html-sitemap/class-posts.php.
- Tìm dòng 88.
- Thay đổi:
$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 - Thành:
$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
Lưu ý rằng bạn có thể cần đặt lại sitemap của mình. Bạn có thể thực hiện việc này bằng cách đi tới Rank Math SEO > Cài đặt sitemap, sửa đổi một cài đặt và thay đổi lại như cũ.