Title: Query all language terms
Last modified: August 20, 2016

---

# Query all language terms

 *  Resolved [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-all-language-terms/)
 * Hi Chouby,
 * In the documentation, I read :
 * >  **_Is it possible to query multiple languages?_**
   >  Yes. Example:
   >     ```
   >     $posts = get_posts(array(
   >         'post_type' => 'post',
   >         'lang' => 'de,fr', // query German and French posts
   >         'showposts' => 5
   >     ));
   >     ```
   > 
 * I have two questions (which might have already been asked and answered but the
   WordPress support forums are impossible to search through) :
 * **1. Is there a way to include all languages without knowing them?**
    Something
   like the parameter ‘lang’ => ‘all’ (or a *, or empty)… If not, is there maybe
   a constant that can be set just like for WP Super Cache will be switched off 
   whenever the constant DONOTCACHEPAGE is set to 1 ?
 * **2. Is there something similar for get_terms() to query all language terms?**
   
   This does not seem to work :
 *     ```
       $terms = get_terms(get_query_var('taxonomy'), array(
           'orderby' => 'count',
           'order' => 'DESC',
           'lang' => 'de,fr', // query German and French posts
           'hierachical' => 0,
           'number' => 50000
       ));
       ```
   
 * and pll_get_term() does not cut it since I need all terms including non-translated
   ones.
 * Or maybe there is a way to loop through all site languages and switch to each
   one dynamically, each time running get_terms() ?
 * [http://wordpress.org/extend/plugins/polylang/](http://wordpress.org/extend/plugins/polylang/)

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/query-all-language-terms/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/query-all-language-terms/page/2/?output_format=md)

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198255)
 * Hello RavanH!
 * You can use:
 *     ```
       global $polylang;
       foreach ($polylang->get_languages_list() as $term)
           $langs[] = $term->slug;
   
       $posts = get_posts(array(
           'post_type' => 'post',
           'lang' => implode(',', $langs),
           'showposts' => 5
       ));
       ```
   
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198288)
 * OK thanks 🙂
 * And for get_terms() could that be done in a similar way?
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198300)
 * Sorry, I missed that one. Clearly Polylang does not provide an easy way to do
   this for the moment. I will come back with a solution.
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198302)
 * Please try the new development version (0.9.5.3). It should now be possible to
   get terms by language just as you expect in the code in your initial post.
    [http://downloads.wordpress.org/plugin/polylang.zip](http://downloads.wordpress.org/plugin/polylang.zip)
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198303)
 * That’s fantastic! I’ll be testing it 🙂
 * I have a suggestion: would it not have some logic to allow for a wildcard in 
   the ‘lang’ array key value?
 * Or rather:
    1. when the lang key is not set, Polylang filters posts (or terms)
   by the current language 2. when the lang key is set and has a value (like ‘de,
   fr’) Polylang filters the languages according to that value [ so far nothing 
   new, but then ] 3. when the lang key _is_ set but has _no_ value (like ”) Polylang
   does _not_ filter by language(s)
 * Similar to some other parameter key / value pairs work in WordPress query functions.
 * You see, while adding a ‘lang’ key / value is without risk (because it will simply
   be ignored when Polylang is not installed) but the foreach loop to check for 
   configured languages will have to be wrapped in an if statement to make sure 
   the $polylang object is set and even then it might break some day (in the far
   future) if you ever decide to somehow alter how languages are stored in the polylang
   object affecting how get_languages_list() returns.
 * Well, a lot of ifs and I trust you are keen to keep the objects public functions
   consistent so it’s just a suggestion 🙂
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198353)
 * Hi Chouby,
 * I notice that this does not work anymore in later versions than 0.9.5.3 … Was
   the ‘lang’ array value for get_terms() dropped? I’d really love to have this 
   back again 🙂
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198354)
 * For sure not! But I introduced a bug when refactoring things to support the same
   for comments. It should work now in the current development version (1.0.1.6)
   
   [http://downloads.wordpress.org/plugin/polylang.zip](http://downloads.wordpress.org/plugin/polylang.zip)
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198355)
 * Yep, that works again! Thanks 🙂
 * Any chance you could consider my earlier suggestion?
 * > 1. when the lang key is not set, Polylang filters posts (or terms) by the current
   > language
   >  2. when the lang key is set and has a value (like ‘de,fr’) Polylang
   > filters the languages according to that value [ so far nothing new, but then]
   > 3. when the lang key is set but has no value (like ”) Polylang does not filter
   > by language(s)
   > Similar to how other parameter key / value pairs work in WordPress query functions.
 * 😉
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198356)
 * There is a problem with the development version:
 * When NOT having configured any menus but simply relying on the default WordPress
   generated one, on a Twenty Eleven site, I notice the menu items are no longer
   filtered by language…
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198357)
 * Oh, and the admin section language filter (in the top nav) does not seem to work
   anymore…
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198358)
 * Hi!
 * I reproduced the bug with the default menu (in fact, it affects all lists of 
   pages). I will update the development version soon.
 * But I don’t have any issue with the admin language filter.
 * Regarding your suggestion (3), I will try to look at this in the future (I write
   that in my todo list), but don’t expect this soon. You know…
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198360)
 * > Regarding your suggestion (3), I will try to look at this in the future (I 
   > write that in my todo list), but don’t expect this soon. You know…
 * I know, and I completely understand. For now, my xml sitemap plugin uses a dedicated
   polylang get languages routine 🙂
 * Regarding the admin language filter, I found that I was clicking the radio buttons
   and not the text. When you do that, you’ll notice that you can activate all radios
   at the same time but nothing happens… Only when you click the text, the page 
   refreshes and comes back with the filtered posts. Not a big issue but still, 
   it confused me a bit 😉
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198362)
 * Strange. Can you reproduce in other browsers?
 *  Thread Starter [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198363)
 * You’re right, it seems to be only happening in Chrome/Chromium but not Firefox
   or Opera. Did not test others…
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/query-all-language-terms/#post-3198365)
 * So I fear I can’t do nothing to help… Basically, I pass html to WordPress functions.
   Nothing special…

Viewing 15 replies - 1 through 15 (of 25 total)

1 [2](https://wordpress.org/support/topic/query-all-language-terms/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/query-all-language-terms/page/2/?output_format=md)

The topic ‘Query all language terms’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

## Tags

 * [get_terms](https://wordpress.org/support/topic-tag/get_terms/)

 * 25 replies
 * 3 participants
 * Last reply from: [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/query-all-language-terms/page/2/#post-3198390)
 * Status: resolved