• Hi,
    I have a website in both English and Spanish languages, and I am using Polylang plugin to manage the content. When the Archives Widget posts are expanded, whatever is the language, all of them, in both languages, are displayed. So, I wonder if it’s possible to display only the posts for each respective language.
    Thank you so much and congratulations for such a great plugin ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Ashley

    (@nosegraze)

    Hi @feldes ??

    Do you have a link to the page that shows this problem? Just to help me see it in more detail.

    Thanks!

    Thread Starter feldes

    (@feldes)

    Thank you Ashley for your reply.

    Sure, here it is:
    https://lapildoradelsaber.com/en/

    Scroll down till the ‘Archives’ widget on the sidebar and display any month. You will see the posts ‘twice’, in English and in Spanish. And I would like them to be displayed ‘once’, just on its respective language.

    Let me know if you need more assistance. Thanks ??

    Plugin Author Ashley

    (@nosegraze)

    Which version of Polylang are you using?

    I tried to reproduce this on my test site but wasn’t able to. I only get the single post.

    Just trying to figure out why I can’t reproduce it. Maybe we’re using different Polylang versions or settings.

    Thread Starter feldes

    (@feldes)

    I am using the latest one (3.2.2). And these are my settings: https://prnt.sc/46WkCysouqfU

    So, according to your words, do you only get the single post on its respective language?

    The next screenshot shows how I am watching it when I browse the English version of the website: https://prnt.sc/RGb3YTGteE6Q

    As you may see, it displays the both two posts, in English and Spanish, instead of just the one in English. The same happens when browsing the Spanish version.

    Thanks!

    Plugin Author Ashley

    (@nosegraze)

    Thanks for that information. I was able to reproduce it now. (Turns out I was doing something kind of silly.)

    It looks like this is an issue with Polylang simply returning _all_ posts. (After all, each translation is actually a separate post.)

    I’m looking to see if there’s an easy solution to this. This is how you can filter the posts to a specific language only:

    add_filter('expanding_archives_get_posts', function($args) {
        $args['lang'] = 'en';
    
        return $args;
    });
    

    Though of course it will take more work to actually dynamically change the language based on which one is currently being shown. I’ll get back to you on that after I see if there’s an easy solution.

    Thread Starter feldes

    (@feldes)

    Exactly, posts are duplicated, each of them in their respective language. It’s not like other plugins/methods where just a post in a default language is translated into different ones, not being necessary to duplicate content.

    Sounds good!
    Thank you so much for your help and patience ??

    Any updates with this? I’m facing the same issue. I use WPML for translations.

    @nosegraze Where should this code snippet be added?

    add_filter('expanding_archives_get_posts', function($args) {
        $args['lang'] = 'en';
    
        return $args;
    });
    Plugin Author Ashley

    (@nosegraze)

    @manisr That goes in a custom plugin or it can go in your theme’s functions.php file.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Filtering displayed widget posts by language’ is closed to new replies.