• Resolved bej-soan

    (@bej-soan)


    Hello,

    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.
    http://pastebin.com/ZcduJaSR

    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.

    https://wordpress.org/plugins/polylang/

Viewing 1 replies (of 1 total)
  • Thread Starter bej-soan

    (@bej-soan)

    Hi everyone, 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.

    http://pastebin.com/Q1ZgQMJS

Viewing 1 replies (of 1 total)
  • The topic ‘Display 1 Post per taxonomy only gives 1 Language’ is closed to new replies.