- الحالة
- مفتوحة
- وسوم الموضوع
- Bug
نظرة عامة على المشكلة
عندما تعيّن مصطلحات للمقالات، يخزّن WordPress إجمالياً تراكمياً لعدد المقالات التي عُيّن لها مصطلح معين.
إذا أزلت مصطلحاً من مقالة ما، ينقص العدد. إذا كانت الإعدادات مضبوطة على مزامنة المصطلحات، فسيُزال المصطلح المترجم من المقالة المترجمة، لكن العدد لا ينقص.
حل بديل مؤقت
يمكنك إضافة مقتطف الكود التالي (عبر إضافة، أو ملف functions.php الخاص بقالبك) لفرض إعادة حساب أعداد المصطلحات للترجمات:
add_action( 'deleted_term_relationships', function($object_id, $tt_ids, $taxonomy){
$trids = array();
$translated_tt_ids = array();
foreach ($tt_ids as $tt_id) {
$trids[] = apply_filters( 'wpml_element_trid', NULL, $tt_id, 'tax_'.$taxonomy );
}
foreach ($trids as $trid) {
$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, 'tax_'.$taxonomy );
foreach ($translations as $lang => $translation) {
$translated_tt_ids[] = $translation->element_id;
}
}
$translated_tt_ids = array_diff( $translated_tt_ids, $tt_ids );
if ( count( $translated_tt_ids ) ) {
wp_update_term_count( $translated_tt_ids, $taxonomy );
}
}, 11, 3);