跳过导航

Open

Topic Tags: Compatibility

Overview of the issue

When using Ultimate Addons for Elementor with WPML, the Post Grid Filter does not display translated category terms in secondary languages. Categories appear only in the default language.

Workaround

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

  • Open …/wp-content/plugins/ultimate-elementor/modules/posts/template-blocks/skin-style.php file.
  • Look for line 1088.
  • Replace:
    $filter_type = $settings[ $filter_by . '_' . $post_type . '_filter_rule' ];
    
    $filters = $settings[ 'tax_' . $filter_by . '_' . $post_type . '_filter' ];
    
  • With:
    $filter_type = $settings[ $filter_by . '_' . $post_type . '_filter_rule' ];
    
    // WPML Workaround for compsupp-7728
    if (class_exists('Sitepress')) {
    	$original_terms = $settings[ 'tax_' . $filter_by  . '_' . $post_type . '_filter' ];
    	$translated_terms = [];
    
    	foreach ($original_terms as $term_slug) {
    		$term_obj = get_term_by('slug', $term_slug, $filter_by );
    		
    		if ($term_obj) {
    			$translated_term_id = apply_filters('wpml_object_id', $term_obj->term_id, $filter_by , true);
    			$translated_term = get_term($translated_term_id, $filter_by );
    			if ($translated_term && !is_wp_error($translated_term)) {
    				$translated_terms[] = $translated_term->slug;
    			}
    		}
    	}
    
    	$settings[ 'tax_' . $filter_by  . '_' . $post_type . '_filter' ] = $translated_terms;			
    }
    
    $filters = $settings[ 'tax_' . $filter_by . '_' . $post_type . '_filter' ];
    

留下回复

紧扣主题并尊重他人。如果您需要帮助解决与本帖无关的问题,请使用我们的 Support Forum 开始聊天或提交票据。

您可以使用这些标签:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>