• Hello

    Great plugin! An issue though:

    I have a Blog with Polylang installed, running two languages. The blog works fine until I try to remove a category from the loop.

    If I write the following
    <?php query_posts('cat=-23'); ?>

    Just before the
    <?php if ( have_posts() ) : ?>

    What happens is: every post from BOTH languages is listed, minus posts from that one category.

    So my question: How can I remove one or multiple categories from the loop and still display only posts from the current language?

    Thank you very much!
    Meanwhile I’ll keep investigating the issue

    Regards

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi there,
    I love the plugin but I have similar problem.
    But I hope I will find the way how to resolve this problem.
    (I am using porcelain theme)
    I have 3 languages and normal sites works great.
    But when its come to portfolio:
    for just one language it is work fine.
    But when I have add translated categories to the other languages –
    on “all” PL I have all things from EN categories – categories list disappeared
    on “all” EN I have all thing that belongs to PL categories – no categories list
    on “all” RU I have, categories list, and all things for |PL language.

    link to the page: https://klienci.rabu.pl/makow/oferta-dla-cateringu-hurtu-i-przemyslu/
    It is working in here like I need to exclude some categories – and it not works.

    One more thing when I haven’t any object in RU category then,
    PL and EN versions had category list like it is now on RU,
    and when You clicked on certain category then You had what you picked.
    but in “all” there were: on PL – English object, on EN – polish objects.

    Thank You for your look up!

    Plugin Author Chouby

    (@chouby)

    @tiago ADPS

    I believe that your problem is that you totally reset the query. You should keep existing query vars with something like

    global $wp_query;
    query_posts(array_merge($wp_query->query, array('category__not_in' => 23)));

    @zofijeczka
    As per forum rules, please don’t pollute this thread and open a new one, as your question is not the same.

    Thread Starter Tiago ADPS

    (@tiago-adps)

    Hello Chouby,

    Thank you for the answer.

    The problem still persists though.
    The original code is working as it should, but if I use:

    <?php global $wp_query;
    query_posts(array_merge($wp_query->query, array('category__not_in' => array( 61, 85 )))); ?>

    Right before the:
    <?php if ( have_posts() ) : ?>

    Both categories are removed, but all the posts from the second language are added.

    Am I doing something wrong? I’m sorry if so, but my php skills are very… moderate.

    Thank you very much once more.

    Thread Starter Tiago ADPS

    (@tiago-adps)

    Any other thoughts on this? Is it a bug or am I doing something wrong?

    Thank you

    Hi Tiago ADPS,

    It’s a long time but have you find a way to solve that issue ?

    I’m facing something similar now.

    Cheers

    Thread Starter Tiago ADPS

    (@tiago-adps)

    If I remember right, I had to work it out fast so I just built a custom page for the blog that called a category named… well “Blog”.
    This way all the other categories weren’t listed and Polylang worked fine.
    I worked around it basically ??

    But I would be more sure about this if I remembered which project I was working at the time. I tried to look at a list, but I can’t pinpoint this case exactly.

    OK, thanks your fast answer. I will somehow else ??

    morollian

    (@morollian)

    Hello Chouby, Tiago ADPS and 916VT.

    I’m facing the same trouble now.
    I love polylang, but it look like it’s not working when I try to exclude a category.

    Here is my code:

    global $wp_query;
    
     $args = array(
            'post_type' => 'post_type',
            'posts_per_page' => 20,
            'order' => 'DESC',
            'cat' => '-46'
            );
    
     $wp_query = new WP_Query($args);

    When I try to exclude the category 46, I get all the post of the post type ‘post-type’ in all languages.

    Am I doing something wrong?
    Thanks a lot!

    916VT

    (@vincent916)

    Add to your array something like :

    'lang' => 'fr_FR'

    (fr_FR is may be not the right way to select the langage)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Exclude category from loop, the Polylang way’ is closed to new replies.