<?php
/**
* Manually translate taxonomy terms
*
* Change $facet_name
* Change $tax_name
*/
add_filter( 'facetwp_facet_display_value', function( $label, $params ) {
$facet_name = 'my_facet_name';
$tax_name = 'my_tax_name';
if ( $facet_name == $params['facet']['name'] ) {
$current = ( !empty( FWP()->facet->http_params['lang'] ) ) ? FWP()->facet->http_params['lang'] : apply_filters( 'wpml_current_language', null );
$default = apply_filters('wpml_default_language', NULL );
if ( $current != $default ) {
$translated_id = apply_filters( 'wpml_object_id', $params['row']['term_id'], $tax_name, TRUE, $current );
$term = get_term( $translated_id );
if ( ! empty( $term ) ) {
$label = esc_html( $term->name );
}
}
}
return $label;
}, 10, 2 );