- Trạng thái
- Đang chờ nhà phát triển
- Plugin/giao diện liên quan
- Custom Permalinks
- Thẻ chủ đề
- Compatibility
Tổng quan về lỗi
Khi sử dụng Đường dẫn tĩnh tùy chỉnh với WPML, các liên kết nội bộ đến các trang đã dịch có thể trỏ đến trang bằng ngôn ngữ gốc thay vì trang đã dịch khi trang đích sử dụng đường dẫn tĩnh tùy chỉnh.
Giải pháp tạm thời
Vui lòng đảm bảo bạn có một bản sao lưu toàn bộ trang web trước khi tiếp tục.
Giải pháp tạm thời – Phần I
- Mở tệp …/wp-content/plugins/custom-permalinks/includes/class-custom-permalinks-frontend.php.
- Tìm dòng 165.
- Thay thế:
public function wpml_permalink_filter( $permalink, $language_code ) { $custom_permalink = $permalink;
- Bằng:
public function wpml_permalink_filter( $permalink, $language_code ) { $custom_permalink = $permalink; $language_code = apply_filters( 'wpml_current_language', NULL );
Giải pháp tạm thời – Phần II
- Trong cùng tệp đó (class-custom-permalinks-frontend.php).
- Tìm dòng 913.
- Thay thế:
public function custom_page_link( $permalink, $page ) { $custom_permalink = get_post_meta( $page, 'custom_permalink', true ); if ( $custom_permalink ) { $language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $page, 'element_type' => 'page', ) ); $permalink = $this->wpml_permalink_filter( $custom_permalink, $language_code );
- Bằng:
public function custom_page_link( $permalink, $page ) { $custom_permalink = get_post_meta( $page, 'custom_permalink', true ); if ( $custom_permalink ) { $language_code = apply_filters( 'wpml_element_language_code', null, array( 'element_id' => $page, 'element_type' => 'page', ) ); $page_translated = apply_filters( 'wpml_object_id', $page, 'page', $language_code ); $custom_translated_permalink = get_post_meta( $page_translated, 'custom_permalink', true ); if ( $custom_translated_permalink ) { $custom_permalink = $custom_translated_permalink; } $permalink = $this->wpml_permalink_filter( $custom_permalink, $language_code );