wordpresspolylang

Show default language content if no translation for post


I have a multilingual Wordpress site with plugin Polylang and the problem is that when I'm seeing site in other language the posts are not showing if there is no translation for the post.

$latest_blog_posts = new WP_Query( array( 'posts_per_page' => 15 ) );
            if ( $latest_blog_posts->have_posts() ) : while (
$latest_blog_posts->have_posts() ) : $latest_blog_posts->the_post(); ?>

I'm using above code to call for the posts, but for now I have posts only in default language (Only posts not pages or categories or any other thing) and everythings OK when I'm seeing site in default language, but when I switch to another one - no posts are shown as there are no translations in other language.

Can anyone help me with this issue. I want to show default language posts if there is no translation.


Solution

  • I found the solution and its very simple :) just added 'lang' => '' in array

    $latest_blog_posts = new WP_Query( array( 'posts_per_page' => 15, 'lang' => '' ) );
                if ( $latest_blog_posts->have_posts() ) : while (
    $latest_blog_posts->have_posts() ) : $latest_blog_posts->the_post(); ?>