Skip Navigation

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.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>