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 a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

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

Let's Talk