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.

 * Polylang support for Display Posts Shortcode
 * @author Bill Erickson
 * @link 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 );

To list posts in french, use

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk