问题概述
如果您在关系或文章对象字段中为相关文章使用了自定义顺序,您会发现在翻译文章时该顺序没有被保留。相反,文章将按 ID 排序。
临时解决方法
这个问题已修复。 更新到最新版本即可在您的站点上解决此问题,因此,只有当您暂时无法更新时,才需要此临时解决方法。
您可以将此代码片段添加到主题的 functions.php 文件中。
请注意,显示为
type=relationship
的部分,您可能需要更改为
type=post_object
具体取决于您使用的文章类型。
add_filter( 'acf/load_value/type=relationship', 'format_order' );
function format_order( $value ){
$lang = apply_filters( 'wpml_current_language', null );
foreach ($value as $key => $id) {
$type = get_post_type($id);
$value[$key] = apply_filters( 'wpml_object_id', $id, $type, true, $lang);
}
return $value;
}