you can add the lang parameter to your loop arguments like so
$loop = new WP_Query( array (
'post_type' => 'post',
'lang' => pll_current_language('slug'), //returns 'en' for example
'posts_per_page' => 10,
'post_status' => 'publish',
) );
However this is not the better practice because by doing that way we override the main query which is not wp friendly.
We should better do like this using the pre_get_post action hook, so in your functions.php file:
if(function_exists('pll_current_language')) // if polylang
{
add_action( 'pre_get_posts', 'include_language' );
function include_language( $query )
{
if ( $query->is_main_query() ) { //add more condition here if needed
$query->set( 'lang', pll_current_language('slug') );
}
}
}
Related Posts:
- When using global $post in blog index file (home.php) it returns the latest blog post instead of current page
- Creating a new blog using PHP
- Is the “Posts page” really required? Can problems occur if I leave it blank?
- multiple blogs on single site
- Building articles grid
- Having trouble showing more blog posts on my grid blog layout
- Separate blog on one WordPress
- How to reverse wp pages links?
- Host a blog engine in my wordpress site
- How do I set up “blog” posts to a page other than the main/home page?
- Why is the_permalink not working?
- show scheduled posts in the calendar
- There is no link or button to my blog page
- How do i remove Responsive navigation bar from from single blog post
- How to show page content as well as post lists
- Latest post showing up as main title of page on blog page
- Archive posts on showing current page instead of archive
- Blog page is not showing properly
- How to list blog post from subdirectory wordpress install to the main site
- Check if current page is the Blog Page
- Creating custom blog page template the right way
- How to show all available images in WP’s media library when using the Polylang plugin?
- Show Default Editor on Blog Page ( Administration Panel )
- How to manually link posts to each other in WordPress
- WP_Query and polylang issue
- custom theme: english .mo file not working
- I put my blog on a subpage, how do I get page title?
- ID for posts/blogs page
- What is archive.php used for?
- Display content from a specific category
- create users to site with specific language
- polylang translation of a custom post created by wp_insert_post()
- detect the language a post is written in
- Polylang – Remove slug of homepage in secondary language
- Blog.php or how to display recent posts?
- Non existing blog pages are not redirected to 404
- Permalink: postname EXCEPT for blog
- Custom fields won’t display on my blog page
- Exclude category on blog list page
- index.php template is used instead of blog page
- How to change the permalink structure of a master page?
- How to change the link structure of the homepage?
- How to query ‘posts_per_page’ to display a different blog posts index template?
- How to get the list of posts in a static page other than front page?
- Get Polylang available languages on admin page of my plugin [closed]
- Why aren’t my posts showing?
- is_page(id) not working for blog page
- How can I have a static title on my blog page?
- Polylang get non-current language/s
- How to display blog posts on a dedicated page?
- How can I show the actual content of Posts page because the_content() is showing all blog content?
- How to display only the excerpt in the blog/posts page with Gutenberg?
- WordPress multilingual site using page-id.php files
- Custom Theme Blog page not showing Posts
- Polylang: pll_e() & pll__() on functions.php, doesn’t work
- WordPress multilingual website domain and folders
- Automatically adding post and pages to new blog setups
- Header Button Chance Polylang Elementor
- I am having trouble with article formatting when exporting/importing articles from the production to the development environments
- Setting a static home page and blog page without using the settings
- How to block access to blog-page for users not logged in?
- get_locale() behaving strange in same functions.php file
- Using polylang, how can I see which post is the “original” and which are the “translated children”? [closed]
- Changing next and previous post link text
- Defining different theme for Blog posts page
- Replicating the WP_Query ‘s’ param with $wpdb
- Multiple Blogs on one site. Best Practise
- How do I make the homepage as the blog page?
- How to link 2 categories (Sync)
- Create a front page template and separate page for posts?
- home.php not loading
- Blog Posts not showing title
- Should I include colon in my msgid in PO file?
- Using variables in polylang string translations
- Adding parent pages to posts
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Allow a static page to show on a dynamic home blog page before the posts
- How to create Blog Post Specific Widget
- Show the page title on blog page
- Do I need an empty page for a different blog page?
- How do I get blog posts to appear within CMS?
- Can I install/embed WordPress on a ‘single page’?
- Front page with registered query params in URL shows blog archive instead of front page
- What to write in the htaccess in order to detect browser language and point accordingly?
- Custom post ui plugin & WP_Query – Polylang
- Hide Polylang metabox from the post edit sidebar
- How to get the webshop page in 2:nd language, with Polylang and Hyyan
- Translations appear in the WP Customizer, but not on the website!
- Polylang post_translations key [closed]
- Changing the search url according to language
- How to import multiple language mutations to polylang?
- Apply a style for 4 blogs and another style for the next 4 blogs in wordpress blog page?
- Posts gathered from WPEMatico feeds are being mixed in different languages. Polylang is used for language separation
- Polylang non-default language ignores tags in WP_Query
- Remove Category slug from link
- Multisite – Parent site with Polylang with different domains for each language [closed]
- Blog page Server error 500 with stick post loop in query.php
- polylang + category/tag custom language link
- WP_Query post_parent parameter always returns children of current page
- Problem with Comment link in Blog [closed]