Saltar navegación

Open

Topic Tags: Compatibility

Overview of the issue

Users of the Filter Everything plugin combined with Advanced Custom Fields may encounter issues where ACF field values used in filters are not translated on the frontend. This problem occurs despite the fields being translated within the WPML String Translation.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Add the following code to the theme’s functions.php file:
    // WPML Workaround for compsupp-7581
    add_filter('wpc_terms_before_display', 'wpml_compsupp7581_filter_wpc_filter_terms', 10, 4 ); 
    
    function wpml_compsupp7581_filter_wpc_filter_terms($terms, $filter, $set, $urlManager) {
    	
    	if ( class_exists('Sitepress') ) {
    		foreach ($terms as &$term ) {
    			$label = $term->name;
    			$textdomain = 'WordPress';
    			$string_name = 'WPC Filter Label: '.substr($label, 0, 40);
    
    			if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
    				do_action( 'wpml_register_single_string', $textdomain, $string_name, $label );
    			}	
    			// Apply the translation to the string
    			$term->name = apply_filters('wpml_translate_single_string', $label , $textdomain, $string_name);
    
    		}
    	}
    	return $terms;
    }
    
  • Visit the page with the issue in the original language. This action will register the string.
  • Go to WPML > String Translation page and translate the string. It should be under WordPress textdomain.

Deje una respuesta

Por favor, mantente dentro del tema y sé respetuoso con los demás. Si necesitas ayuda con cuestiones no relacionadas con este post, utiliza nuestro Foro de soporte para iniciar un chat o enviar un ticket.

Puede utilizar estas etiquetas:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>