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
* @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

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