Polylang support for Display Posts Shortcode

If you are using Polylang or Polylang Pro to translate content on your website, you can also query by posts in a specific language. See the documentation for more information.

Add the following code to your theme’s functions.php file or a core functionality plugin.

<?php
/**
* Polylang support for Display Posts Shortcode
*
* @author Bill Erickson
* @see https://wordpress.org/support/topic/display-posts-in-a-specific-language/
*
* @param array $args, WP Query arguments
* @param array $atts, Shortcode attributes
* @return array $args
*
*/
function be_polylang_support_dps( $args, $atts ) {
if( !empty( $atts['lang'] ) )
$args['lang'] = esc_attr( $atts['lang'] );
return $args;
}
add_filter( 'display_posts_shortcode_args', 'be_polylang_support_dps', 10, 2 );
view raw functions.php hosted with ❤ by GitHub

To list posts in french, use [display-posts lang="fr"]

Display Posts Shortcode