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
- How to show all available images in WP’s media library when using the Polylang plugin?
- How to manually link posts to each other in WordPress
- 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
- Display content from a specific category
- Polylang – Remove slug of homepage in secondary language
- Permalink: postname EXCEPT for blog
- Custom fields won’t display on my blog page
- Get Polylang available languages on admin page of my plugin [closed]
- 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 only the excerpt in the blog/posts page with Gutenberg?
- WordPress multilingual site using page-id.php files
- WordPress multilingual website domain and folders
- Setting a static home page and blog page without using the settings
- How to block access to blog-page for users not logged in?
- Changing next and previous post link text
- home.php not loading
- 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
- Custom post ui plugin & WP_Query – Polylang
- How to get the webshop page in 2:nd language, with Polylang and Hyyan
- Polylang post_translations key [closed]
- How to import multiple language mutations to polylang?
- Polylang non-default language ignores tags in WP_Query
- Remove Category slug from link
- polylang + category/tag custom language link
- WP_Query post_parent parameter always returns children of current page
- get_comments not working consistantly with post_id
- Blog page problems
- Get the ID of the default language equivalent page in Polylang [closed]
- Polylang not translating Metabox fields [closed]
- How to Get The Excerpt of the page that displays Blog Posts
- WP/WooCommerce multisite with polylang, product duplication between websites [closed]
- How to translate custom Divi module using POEDIT and Polylang [closed]
- Site shows URL instead of “meta title” after deleted few plugins (not any SEO plugin was deleted)
- How to Customize Polylang Language Items
- How to set a certain Custom Template to a Single Blog Post
- How to copy [gallery] shortcode between posts using polylang [closed]
- Multiple Blog Pages
- Show preview of wordpress posts on external html sever
- Translate website without duplicate custom post
- Show only Current category and sub category of custom post wordpress
- “Blog pages show at most” in setting not working
- Use a 301 to Redirect any 404 from at the blog post level to the blog archive
- Translate Post date (month) of china language
- different domains disabled in polylang
- Page Template Selector Error
- Polylang will not allow changing of language without translation
- Update around 200,000 posts
- WordPress blog posts template bug [closed]
- Multilanguage backend interface
- Redirect Category pages to blog page with query string
- Blog post Links leading to home page [closed]
- How to make “virtual” translation with polylang installed (but without Polylang)
- phantom language switcher
- Polylang plugin translation problems
- Function get_locale always returns en_US in plugin?
- Allowing Comments on Posts
- How to put the WordPress blog into theme
- Blog Post Title apearing twice
- Internationalize Forum Posts Without Translating Them
- Static home page ignored
- Polylang and United Arab Emirates languange
- why custom post archive gives always no more than 10 posts despite of paging settings?
- Limit the number of posts from a specific category on index.php
- Having single posts appear under the blog homepage and highlight menu items properly?
- Posts page drop down is not selecting the selected page
- why is this content-template not showing any of my blog-entries?
- Overwrite URL on blog posts
- Older entries link within a category page
- Pulling sub-site content into specific pages
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- Blog page id different then in main menu
- Where Language settings stored in MySQL multilingual Polylang website?
- custom wordpress theme blog page always not showing the last two pages of the articles