• Hi chouby,

    on my static frontpage I want to display posts from the current language. In your plugin documentation you write that you can do this with the following code:

    $posts = get_posts(array(
        'post_type' => 'post',
        'lang' => 'fr', // use language slug in the query
        'showposts' => 5
    ));

    When I add the lang param to my get_posts function, the returned array is empty. If I do not set the lang param, the systems returns posts from all languages. Can you help me?

    My code:

    $teasers = get_posts([
            'post_type' => 'post',
            'cat' => $category_id,
            'posts_per_page' => $parameters['small'] ? 2 : 3,
            'post__not_in' => [$featured_id],
            // 'lang' => get_query_var('lang')
            'lang' => 'de' // display just german posts
        ]);

    https://www.ads-software.com/plugins/polylang/

  • The topic ‘Get posts from one language not working’ is closed to new replies.