- 상태
- 개발자 대기 중
- 관련 플러그인/테마
- WP Grid Builder
- 주제 태그
- Compatibility
문제 개요
WPML 및 Advanced Custom Fields (ACF)와 함께 Grid Builder를 사용할 때 사용자 정의 필드를 사용하는 Facets에 문제가 있습니다. 백엔드에서 ACF 필드 레이블이 번역되더라도 프런트엔드에는 반영되지 않습니다.
임시 해결 방법
진행하기 전에 사이트의 전체 백업을 완료했는지 확인하세요.
Select 필드의 경우
- 테마의 functions.php 파일을 여세요.
- 다음 코드를 추가하세요:
// WPML Workaround for wpmlsupp-11647 function wpml_wpmlsupp11647_translate_facet_choices( $choices, $facet ) { if ( class_exists('Sitepress') ) { foreach ($choices as &$choice) { $string = $choice->facet_name; $textdomain = 'facets'; $string_name = 'Facet: '.substr($string, 0, 20); if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) { do_action( 'wpml_register_single_string', $textdomain, $string_name, $string ); } // Apply the translation to the string $choice->facet_name = apply_filters('wpml_translate_single_string', $string , $textdomain, $string_name); } } return $choices; } add_filter( 'wp_grid_builder/facet/choices', 'wpml_wpmlsupp11647_translate_facet_choices', 10, 2 ); - 문자열을 등록하려면 Facet이 있는 원본 언어 페이지를 방문하세요.
- WPML > 문자열 번역 페이지로 이동하여 문자열을 번역하세요.
참고: Facet이 구성된 방식에 따라 다음 스니펫이 유용할 수 있습니다:
// WPML Workaround for compsupp-7453
function wpml_compsupp7453_translate_facet_block_custom_field( $output ) {
if ( class_exists('Sitepress') ) {
if( is_string($output) ) {
$string = $output;
$textdomain = 'facets';
$string_name = 'Facet: '.substr($string, 0, 20);
if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
do_action( 'wpml_register_single_string', $textdomain, $string_name, $string );
}
// Apply the translation to the string
$output = apply_filters('wpml_translate_single_string', $string , $textdomain, $string_name);
}
}
return $output ;
}
add_filter( 'wp_grid_builder/block/custom_field', 'wpml_compsupp7453_translate_facet_block_custom_field', 99, 2 );