Display 1 Post per taxonomy with polylang

i finally figured out a solution. I guess it’s not the perfect one, because all posts are still looped and the wrong language just doesn’t show, but for now it works. I am still open for ideas.

My idea right now is to get the language of the post and don’t display it if it doesn’t match the pages language.

Here’s the new part.

global $polylang;
$postlang = $polylang->get_post_language(get_the_ID())->slug;

if ($postlang == $lang) {
    get_template_part('project-thumb');
}

The full code now looks like this and is working for me.

<?php get_header() ?>

<div class="row" id="main">
    <div class="large-12 columns">
        <ul class="small-block-grid-3 large-block-grid-6">
        <?php
        global $polylang;
        $lang = pll_current_language();

        $terms = get_terms( 'kunden' );

        foreach( $terms as $term ) :

            $args = array(
                'post_type' => 'portfolio',
                'kunden' => $term->slug,
                'posts_per_page' => 2,
                'lang' => $lang,
            );
            $single = new WP_Query( $args ); ?>
            <?php if ($single->have_posts()) { ?> 

            <?php while ($single->have_posts()) : $single->the_post(); ?>

            <?php $postlang = $polylang->get_post_language(get_the_ID())->slug; ?>

            <?php if ($postlang == $lang) {
                get_template_part('project-thumb');
            } ?>


            <?php endwhile; ?>

            <?php } ?>
        <?php endforeach; ?>
        </ul>
    </div>


</div>


<?php get_footer() ?>

tech