PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 9, 2022

[FIXED] How to display posts in all languages in the plugin Polylang?

 October 09, 2022     polylang, wordpress     No comments   

Issue

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 ...



Answered By - Angel Deykov
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing