How to include language in a query with xili-language ?

$faq_args = array(
        'post_type'      => 'hrf_faq',
        'post_status'    => 'publish',
        'posts_per_page' => -1,
        'orderby'        => 'menu_order',
        'order'          => 'ASC',
        'lang' => xili_curlang()
   );

   if( $faq_params['category'] != '' ){
      $faq_args['category_name'] = $faq_params['category'];
   }

   $faq_query = new WP_Query( $faq_args );

   if( $faq_query->have_posts() ):
      while( $faq_query->have_posts() ):
         $faq_query->the_post();

In the lines above, the WP_Query is called with query vars as in URI. Currently, the result is good because the request will be now transformed in an array of params (and taxonomy).

TIPS: But it is possible to give a better description with arrays passed as below (remember ‘language’ is a taxonomy since 6 years):

 if ( $faq_params['lang'] ) {
	   		$lang_slug = ( $faq_params['lang'] == 'cur') ? xili_curlang() : $faq_params['lang'] ;

	   		$query = array(
				'numberposts' => -1,
				'post_type' => 'hrf_faq',
				'tax_query' => array(
					'relation' => 'AND',

					array(
						'field'    => 'slug',
						'taxonomy' => 'language',
						'terms'    => $lang_slug,
					),
				),
			);
			if ($faq_params['category'] != '') {
				$query['tax_query'][] = array(
						'field'    => 'slug',
						'taxonomy' => 'category',
						'terms'    => explode (',', $faq_params['category'])
					);

			}

		} else {
			$query = array(
				'numberposts' => -1,
				'post_type' => 'hrf_faq'
				);

			if ($faq_params['category'] != '') {
				$query['tax_query'] = array(
					array(
						'field'    => 'slug',
						'taxonomy' => 'category',
						'terms'    => explode (',', $faq_params['category'])
					));

			}

		}

		$faqs = new WP_Query( $query ) ;
		if ($faqs) {
			while ( $faqs->have_posts() ) : $faqs->the_post();

				$ID = get_the_ID();

For more accurate query, it will be easier to introduce others parameters (taxonomy, custom fields (meta), sorting…)..

Reference in codex.

Post including shortcode by xili-postinpost

This post in english includes a shortcode with posts (post_type named “event”) :

No February 29th

In 2015, there was no February 29th because the year is not a leap year:-(

New Year

The first day of 2015. A thursday January the first ! Happy new Year !

Christmas

The day of Santa Klaus ! On Thursday December 25 !

Shorcode is: [xilipostinpost query='post_type=event' showposts=3 lang='cur']

And now the same list but with events like Molière speaking :

Pas de 29 février !

En 2015, il n’y a pas de 29 février car l’année n’est pas bissextile 🙁

Nouvel AN

Le premier jour de l’année 2015. C’est la nouvelle année ce jeudi 1er Janvier, Bonne année !

Le code : [xilipostinpost query='post_type=event&lang=fr_fr' showposts=2]

Note that only if the target language is known, the slug is inside query, otherwise it is a param of the shortcode !
Shortcode is from plugin “xili-postinpost” !