WPML
סטטוס
ממתין למפתח
תוסף/ערכת עיצוב קשורים
WP Grid Builder
תגיות נושא
Compatibility

סקירה כללית של התקלה

בעת שימוש ב־Grid Builder עם WPML ו־Advanced Custom Fields (ACF), ישנה בעיה עם 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 );
  • בקר בעמוד עם ה־Facets בשפה המקורית כדי לרשום את המחרוזות.
  • עבור אל העמוד WPML > תרגום מחרוזות ותרגם את המחרוזות.

הערה: בהתאם לאופן שבו ה־Facets שלך נבנו, ייתכן שקטע הקוד הנוסף הזה יהיה שימושי:

// 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 );

כל התקלות הידועות →