Support » Plugin: Polylang » get_terms() ignores ‘lang’?

  • Hi,
    I am using a custom taxonomy with few terms, translated into three languages. I only want to get the terms in the current language, so I am doing this:

    $options = array(
    	'taxonomy' => 'event_category',
    	'hide_empty' => false
    if (function_exists('pll_current_language')) {
    	$options['lang'] = pll_current_language();
    $terms = get_terms($options);

    The $options array then includes ‘lang’ => ‘de’, but I am getting ALL the existing terms anyway. Doesnt matter what I use as the lang parameter, I am getting all the taxonomy terms in the database for the ‘event_category’ taxonomy.

    Is this a bug?

    • This topic was modified 3 years, 10 months ago by Roman Klabal.
    • This topic was modified 3 years, 10 months ago by Roman Klabal.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Roman Klabal


    I have ‘Custom Taxonomy Order NE’ plugin installed and as that might change how the query works, I have disabled it – it didnt help with the issue above.

    does you use Polylang or polylang pro ?

    Thread Starter Roman Klabal


    Regular version, not the pro one.

    Sorry, I noticed this issue after installing pro, but on other website, I had same error, and my friend to.
    Wierd thing is

    says it should work. And it worked. Then it stopped.
    It seems to be a some kind of bug.
    I also want point – I use it in WP REST.
    I fixed it using:

    $positions_tax = get_terms( 'pos', $args );
            foreach ($positions_tax as $key => $tax) {
                if(pll_get_term_language($tax->term_id) !== $args['lang']){
            $positions_tax = array_values($positions_tax);

    Sorry for late answer 😉

    Thread Starter Roman Klabal


    Oh yes, loading all the terms/posts and then filtering them manually works, thanks for the useful snippet!

    But I am very surprised there is no response/fix from the plugin author, this seems like a rather serious and annoying bug to me.

    Has this been fixed?I don’t see it working in polylang ( free version )

    Any soon plans to solve this? same issue here.

    • This reply was modified 3 years, 3 months ago by Ali Basheer.
    Samuel Diethelm


    Still an issue today as it seems. I have the issue with MetaBox plugin, all languages are showing when I add

    'query_args' => array(
        'lang' => 'en'

    I don’t want to edit the metabox plugin with the solution from @isuke01 so I have fixed it with the following hook:

    add_filter('get_terms' , 'pll_get_terms_fix', 10, 4);
    function pll_get_terms_fix($terms, $taxonomy, $query_vars, $term_query)
        if(in_array('mytaxonomy',$taxonomy) && function_exists('pll_get_term_language') && isset($query_vars['lang'])){
            foreach ($terms as $key => $term) {
                if($term->taxonomy == 'mytaxonomy' && pll_get_term_language($term->term_id) !== $query_vars['lang']){
            $terms = array_values($terms);
        return $terms;
    Plugin Author Chouby



    I just tested in Polylang 2.3.10

    get_terms( array( 'taxonomy' => 'category' ) ); // returns terms in the current language
    get_terms( array( 'taxonomy' => 'category', 'lang' => '' ) ); // returns all languages
    get_terms( array( 'taxonomy' => 'category', 'lang' => 'en' ) ); returns terms in English

    They all work as expected.

    Samuel Diethelm


    @chouby, have you tried with a custom taxonomy?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘get_terms() ignores ‘lang’?’ is closed to new replies.