- Trạng thái
- Đang mở
- Được báo cáo cho
- WPML SEO 2.1.0
- Plugin/giao diện liên quan
- Rank Math SEO
- Thẻ chủ đề
- Compatibility
Tổng quan về lỗi
Nếu bạn đang sử dụng plugin Rank Math SEO, cụ thể là phiên bản Pro có bật tính năng News Sitemap, bạn có thể gặp phải sự cố trong đó các thẻ <news:language> bên trong tệp news-sitemap.xml hiển thị không chính xác mã ngôn ngữ của ngôn ngữ mặc định của trang web cho các bài viết bằng ngôn ngữ phụ..
Giải pháp tạm thời
Vui lòng đảm bảo bạn có bản sao lưu toàn bộ trang web trước khi tiếp tục.
- Mở tệp …/wp-content/plugins/seo-by-rank-math-pro/includes/modules/news-sitemap/class-news-sitemap.php.
- Thay thế:
$output .= $this->get_news_publication( $renderer );
- Bằng:
//start WPML workaround global $sitepress; remove_filter( 'get_pages', [ $sitepress, 'get_pages_adjust_ids' ], 1 ); $my_post_language_details = apply_filters( 'wpml_post_language_details', NULL, url_to_postid($url["loc"]) ); $xmlString = $this->get_news_publication( $renderer ); $pattern = '/(<news:language>)[^<>]*(</news:language>)/i'; $replacement = '${1}'. $my_post_language_details["language_code"] .'$2'; $modifiedXmlString = preg_replace($pattern, $replacement, $xmlString); $output .= $modifiedXmlString; //end WPML workaround - Ngoài ra, bạn cũng có thể cần tắt bộ nhớ cache của sitemap. Để thực hiện việc này, bạn có thể thêm dòng sau vào tệp functions.php trong giao diện của bạn:
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');