Title: Mixed language post display
Last modified: August 30, 2016

---

# Mixed language post display

 *  [David](https://wordpress.org/support/users/davidbeermann/)
 * (@davidbeermann)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/mixed-language-post-display/)
 * Hey Chouby,
 * I’ve been trying to figure out how to display posts of different languages on
   a single page to no avail so far. My site only uses two languages: en, de. I’m
   using a custom page template where I query the database for posts with a custom
   post type and a custom field. The following query yields the result you’d expect
   for the current language:
 *     ```
       $featured_query = new WP_Query(array(
         'post_type' => 'project',
         'meta_key' => 'featured_project',
         'meta_value' => 'featured',
         'meta_compare' => 'LIKE'
       ));
       ```
   
 * Once I’m adding the _‘lang’_ parameter to this query it either does not return
   any result – for the values _‘de’_ and _‘any’_ – or just the default results –
   for the values _”_, _‘en’_ and _‘en,de’_. Trying to add the languages before 
   or after Polylang processed the query via a filter hook yields the same results.
 * I then tried altering the _‘tax\_query’_ parameter for the language – which is
   only set when the _‘lang’_ parameter is not set in the query.
 *     ```
       add_filter('pre_get_posts', 'set_languages_for_project_posts', 30); // after polylang
       function set_languages_for_project_posts($query)
       {
         if (!is_admin() && function_exists('pll_default_language')) {
           $qv = $query->query_vars;
           if (isset($qv['post_type']) && $qv['post_type'] == 'project') {
             $lang_terms = get_terms('language');
             $term_ids = array();
             foreach ($lang_terms as $lang_term) {
               $term_ids[] = $lang_term->term_id;
             }
             $query->set('tax_query', array(
               array(
                 'field' => 'term_taxonomy_id',
                 'operator' => 'IN',
                 'taxonomy' => 'language',
                 'terms' => $term_ids
               )
             ));
           }
         }
         return $query;
       }
       ```
   
 * But this still renders just the default posts. The _$term\_ids_ array will contain
   two values – _10_ for _en_ and _13_ for _de_. Changing _‘terms’_ to just _13_
   renders no posts at all. Resetting it to _10_ shows also the default posts again.
 * Since both approaches yield similar results I feel like I’m starting at the wrong
   end to achieve my goal. Can you point me into the right direction?
 * Thanks.
    David
 * Resources considered:
    - [GOING MULTI-LINGUAL WITH POLYLANG](http://wordpress.syllogic.in/2014/08/going-multi-lingual-with-polylang/)
    - [Plugin Polylang displays all posts](http://pastebin.com/bsEM0P2R)
 * [https://wordpress.org/plugins/polylang/](https://wordpress.org/plugins/polylang/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/mixed-language-post-display/#post-6340371)
 * Hi!
 *     ```
       $query = new WP_Query(array('lang' => ''));
       ```
   
 * will give you the last posts in all languages (just re-tested it to check that
   it works).
    see [https://polylang.wordpress.com/documentation/documentation-for-developers/general/](https://polylang.wordpress.com/documentation/documentation-for-developers/general/)

Viewing 1 replies (of 1 total)

The topic ‘Mixed language post display’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [Chouby](https://wordpress.org/support/users/chouby/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/mixed-language-post-display/#post-6340371)
 * Status: not resolved