I'm using this line to get all the posts with the category "Upcoming Event"

$wpb_all_query = new WP_Query(array('post_type'=>'post', 'category_name' => 
'Upcoming Event', 'post_status'=>'publish', 'posts_per_page'=>6, 'paged' => 
$paged ));

its working fine, the issue is that there's an Arabic version of that page and I want to show the Arabic posts that have the category "Upcoming Event AR".

I tried using this:

    if (get_locale() == 'en_US') {
        $wpb_all_query = new WP_Query(array('post_type'=>'post', 
        'category_name' => 'Upcoming Event', 'post_status'=>'publish', 
        'posts_per_page'=>6, 'paged' => $paged ));
    } else {
        $wpb_all_query = new WP_Query(array('post_type'=>'post', 
        'category_name' => 'Upcoming Event AR', 
        'post_status'=>'publish', 'posts_per_page'=>6, 'paged' => $paged 
        ));
    }   

The English shows on the english version of the page but the arabic doesnt show at all.

Please help :/

  • Do you use any plugin achieve multi language or did you just post two pages in different languages? – kero Dec 7 at 14:19
  • Im using polylang – robin geagea Dec 7 at 14:24
  • 1
    Try pll_current_language() instead of get_locale() then and check Polylang documentation – kero Dec 7 at 14:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.