0

I'm working on a fix to a WordPress multi-language site using WPML. This website has two different domains, one for english and one for french. French is the main language.

For all the website when I retrieve posts the language of the website is respected in the query, but there is a query in the theme's footer.php, to retrieve some alerts, which is returning posts in any language. this is the query:

<?php
$args = array(
    'post_type' => 'post',
    'cat' => 8,
    'posts_per_page' => 1,
    'meta_key' => 'traffic-level',
    'meta_value' => 1,
    'suppress_filters' => false
);

$query = new WP_Query( $args );
wp_reset_query();

if( $query->have_posts() ):

    while( $query->have_posts() ) : $query->the_post();?>

     print the post...

    <?php endwhile;

endif;?>

In all the other pages suppress_filters' => false is not set. I added this because I saw it in the plugin's forum but it's not working properly yet. I also checked my functions.php to see if there was a pre_get_posts action that could be messing with the query and there isn't.

Am I missing something in this query? What else could I do to fix it?

Thanks for any help

2
  • 1
    Are you sure you set the language information correctly for those posts? (Eg they need to have an associated translation)
    – Tofandel
    Commented Mar 11, 2020 at 17:19
  • @Tofandel hi, yes. When I go to the post inside the admin, I can see the link between them. When I go to the french I see there is an english translation and when I go to the post in english it says it's a translation of the french post. Commented Mar 12, 2020 at 12:36

1 Answer 1

0

I was facing the same issue, it seems suppress_filters needs to be set to true so you actually suppress those filters!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.