- الحالة
- في انتظار المطور
- الإضافة/القالب ذو الصلة
- Custom Permalinks
- وسوم الموضوع
- Compatibility
نظرة عامة على المشكلة
عند استخدام Custom Permalinks مع WPML، قد تشير الروابط الداخلية للصفحات المترجمة إلى صفحة اللغة الأصلية بدلاً من الصفحة المترجمة عندما تستخدم الصفحة الهدف رابطاً دائماً مخصصاً.
حل بديل مؤقت
يُرجى التأكد من أخذ نسخة احتياطية كاملة للموقع قبل المتابعة.
الحل البديل المؤقت – الجزء الأول
- افتح الملف …/wp-content/plugins/custom-permalinks/includes/class-custom-permalinks-frontend.php.
- ابحث عن السطر 165.
- استبدل:
public function wpml_permalink_filter( $permalink, $language_code ) { $custom_permalink = $permalink;
- بـ:
public function wpml_permalink_filter( $permalink, $language_code ) { $custom_permalink = $permalink; $language_code = apply_filters( 'wpml_current_language', NULL );
الحل البديل المؤقت – الجزء الثاني
- في نفس الملف (class-custom-permalinks-frontend.php).
- ابحث عن السطر 913.
- استبدل:
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 );
- بـ:
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 );