I am trying to make a loop where I display all my taxonomies with the first post of every taxonomy. It's the taxonomy "customers"
and I want to display every first portfolio-CPT of the customer.
I have polylang with english and german language installed, all working, instead of this loop.
The Loop is working, but the project always get me the english posts. No matter what language it's set.
Here is a pastebin, just to be clear the customer tax is "kunden"
and the custom post type is "portfolio"
. The "kunden"
-tax is not translated, both language use the same one. The "portfolio"
-cpt is translated.
<?php get_header() ?>
<div class="row" id="main">
<div class="large-12 columns">
<ul class="small-block-grid-3 large-block-grid-6">
<?php
$lang = pll_current_language();
$terms = get_terms( 'kunden' );
foreach( $terms as $term ) :
$args = array(
'post_type' => 'portfolio',
'kunden' => $term->slug,
'posts_per_page' => 1,
'lang' => $lang,
);
$single = new WP_Query( $args ); ?>
<?php if ($single->have_posts()) { ?>
<?php while ($single->have_posts()) : $single->the_post(); ?>
<?php get_template_part('project-thumb'); ?>
<?php endwhile; ?>
<?php } ?>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php get_footer() ?>
If I change post_per_page => 2
the german post is the second one after the english one. So both Languages are displayed one after another.