wordpresspolylang

How to display posts in all languages in the plugin Polylang?


I am using the Polylang plugin and noticed that I cannot display a post simultaneously in all languages. that's why I wondered is there a way to display posts from all languages on the site in a specific place well, or create a separate language where posts from all languages of the site would be displayed

I have to do this so that it works separately from other versions -is -en they would work as usual

but somewhere on the page [multilanguage news] or in versions -full all posts created on different versions of the site would be displayed


Solution

  • You need something like:

    $args = array(
        'post_type' => 'post',
        'lang' => '', // no language specified
    );
    
    $posts = get_posts( $args );
    
    if ( $posts ) {
        foreach ( $posts as $post ) :
            //do whatever
        endforeach; 
        wp_reset_postdata();
    }
    

    This would get you all the posts from all languages, you can add more args to the array if needed ...