- الحالة
- محلولة
- تم حلها في
- 1.2.0
- الإضافة/القالب ذو الصلة
- Yoast SEO
نظرة عامة على المشكلة
بعد التغييرات الرئيسية الأخيرة في الإصدار Yoast 14.x، يلاحظ بعض مستخدمي WPML أن محتوى Yoast يتم إنشاؤه دائماً باللغة الافتراضية.
على سبيل المثال، في صفحة بلغة ثانوية، قد يكون ذلك في وسوم «meta» مثل «og:title» أو «og:description»، أو عناوين URL في مسارات التنقل.
يتوفر لدينا حل بديل مؤقت، ولكن نظراً لطبيعة المشكلة، قد لا ينجح مع الجميع. نعمل على إصلاح هذه المشكلة في أقرب وقت ممكن.
إذا كنت تواجه مشكلة في ترجمة محتوى Yoast، يُرجى تجربة الحل البديل المؤقت أدناه وانتظار الإصدار التالي من Yoast Multilingual قبل إنشاء تذكرة دعم.
حل بديل مؤقت
أضف هذا الكود إلى ملف functions.php في قالبك:
if ( ! is_admin() ) {
add_filter( 'wpseo_title', 'wpml_wpseo_title', 10, 2 );
add_filter( 'wpseo_opengraph_title', 'wpml_wpseo_title', 10, 2 );
}
function wpml_wpseo_title( $title, $presentation ) {
switch ( $presentation->model->object_type ) {
case 'post-type-archive':
$key = 'title-ptarchive-' . $presentation->model->object_sub_type;
break;
case 'system-page':
$key = 'title-' . $presentation->model->object_sub_type . '-wpseo';
break;
default:
$key = false;
}
if ( $key ) {
$option = get_option( 'wpseo_titles' );
if ( isset( $option[ $key ] ) ) {
$title = wpseo_replace_vars( $option[ $key ], $presentation );
}
}
return $title;
}
if ( ! is_admin() ) {
add_filter( 'wpseo_metadesc', 'wpml_wpseo_desc', 10, 2 );
add_filter( 'wpseo_opengraph_desc', 'wpml_wpseo_desc', 10, 2 );
}
function wpml_wpseo_desc( $title, $presentation ) {
switch ( $presentation->model->object_type ) {
case 'post-type-archive':
$key = 'metadesc-ptarchive-' . $presentation->model->object_sub_type;
break;
case 'system-page':
$key = 'metadesc-' . $presentation->model->object_sub_type . '-wpseo';
break;
default:
$key = false;
}
if ( $key ) {
$option = get_option( 'wpseo_titles' );
if ( isset( $option[ $key ] ) ) {
$title = wpseo_replace_vars( $option[ $key ], $presentation );
}
}
return $title;
}
add_filter( 'wpseo_save_indexable', function( $indexable ) {
$args = [
'element_id' => $indexable->object_id,
'element_type' => $indexable->object_type,
];
$language_code = apply_filters( 'wpml_element_language_code', false, $args );
$indexable->permalink = apply_filters( 'wpml_permalink', $indexable->permalink, $language_code, true );
return $indexable;
} );
بعد إضافة الكود، ثبّت إضافة Yoast Test Helper.
اذهب إلى أدوات > Yoast Test وانقر على «Reset Indexables tables & migrations».
أخيراً، اذهب إلى لوحة التحكم وانقر على إشعار الإدارة الذي يطلب منك فهرسة الموقع.
إذا كانت لديك أي أسئلة أو كنت ترغب في الإبلاغ عن مشكلة ذات صلة، يُرجى ذكر هذه المشكلة المعروفة حتى يتمكن فريقنا من تقديم دعم فعّال لك.