#language #multilanguage #translation
Provides an instant overview of your shop's current customers and the contents of their carts.
Since WPML documentation/support is terrible at best, you gotta figure these things out yourself. Since I’ve had to do this more than once, here’s a snippet in case it can help someone else!
global $sitepress;
$taxonomy = 'your-taxonomy-slug';
if ( $sitepress ) {
remove_filter( 'get_terms_args', array( $sitepress, 'get_terms_args_filter' ) );
remove_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ) );
remove_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ) );
$terms = get_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'fields' => 'id=>name' ) );
add_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10, 4 );
add_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1, 1 );
add_filter( 'get_terms_args', array( $sitepress, 'get_terms_args_filter' ), 10, 2 );
}
else {
$terms = get_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'fields' => 'id=>name' ) );
}
The trick is that you temporarily remove the WPML filter hooks that manipulate the term query to only return terms in the current language. You return the filter hooks back to normal after getting the terms back in all languages.
The if ( $sitepress )
is there as a safety measure to avoid errors in case you disable WPML in the future.
Posted by Berend on
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
You are awesome! Thanx, this was very useful!