由于WPML不提供翻译[choices]字段的解决方案,我想添加一个自定义函数来在WPML中注册它,但是我不是php中的明星,但我有以下内容,但它没有在WPML字符串转换中注册它:
$field = get_field_object( 'type_of_property' ); // acf field with choices
if (!empty($field['choices'])) {
foreach( $field['choices'] as $choice ){
do_action( 'wpml_register_single_string', 'ACF Domain', 'name'.$choice , $choice );
$acflabel= apply_filters( 'wpml_translate_single_string', $choice, 'ACF Domain', 'name'.$choice, NULL );
echo ' - ' . $acflabel;
}
}上面的方法是否正确,或者我是否需要调用type_of_property字段中的所有选项?
发布于 2021-02-11 00:36:03
我相信你应该能够做到这一点:
$field = get_field_object( 'type_of_property' );
if ( !empty( $field['choices'] ) ) {
foreach( $field['choices'] as $choice ){
echo ' - ' . __( $choice, 'ACF Domain' );
}
}然后扫描你的主题/插件中的字符串:
在管理仪表板中,转到WPML > Theme Plugins Localization
文档:
https://stackoverflow.com/questions/66138272
复制相似问题