• Resolved nac_87

    (@nac_87)


    Hi, I’m making a website with two languages and the main page has dynamic content using wp_query.

    Today I updated to polylang last version and since then the main page is working properly in the default language. After I press the translation link, the page is not able to get the article data and links through wp_query.

    This is the code I’m using:

    // FEAT
    $args = array(
    		'cat' => '9',
    		'post_type' => 'post',
    		'orderby' => 'rand',
    		'lang' => pll_current_language(),
    		'posts_per_page' => '1',
    		'meta_key' => '_thumbnail_id'
    		);
    $feat_sh = new WP_Query($args);
    
    // LINKS
    $args = array(
    		'cat' => '9',
    		'post_type' => 'post',
    		'orderby' => 'rand',
    		'posts_per_page' => '3',
    		'lang' => pll_current_language()
    		);
    $links_sh = new WP_Query($args);

    This is only working for the main language, before I did the update is was working properly.

    I don’t have the same problems eg. in the archive page using this:

    $current_cat = get_query_var('cat');
    
    $artc = array(
    'cat' => $current_cat,
    'orderby' => 'title',
    'order' => 'ASC' ,
    'paged' => $paged ,
    'showposts'=> '5',
    'post_type' => 'post', // or define custom post type here
    'lang' => pll_current_language()
    );
    
    $articles = new WP_Query($artc);

    Permalinks are displayed in the mode http://www.site.com/article-name

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Chouby

    (@chouby)

    In your 2 first queries, you request posts in cat 9 AND in current language. If the current language is the same as the language of category 9, it’s OK but otherwise it can’t return any post (since a post has only one language). v1.4.3 should not change anything to this.

    Thread Starter nac_87

    (@nac_87)

    Thanks for the reply Chouby. Well believe it or not, it used to work before like that. I thought that the 'lang' => pll_current_language(), row did it automatically.

    Thread Starter nac_87

    (@nac_87)

    a post has only one language but it is associated with another translated post, I supposed that is the way pll_current_language works.

    Plugin Author Chouby

    (@chouby)

    pll_current_language() just returns the current language which has probably been set before your queries are executed (this is the language in which your page is displayed).

    If you just want to get posts in the translation of category 9, just remove this 'lang' => pll_current_language() and in fact Polylang will automatically translate the category for you. (setting ‘lang’ intentionally disables this automatic translation)

    Thread Starter nac_87

    (@nac_87)

    that’s weird, it has been working like that for a long time using this 'lang' => pll_current_language() , but now it works as you said…I tested it now and it’s true, it works!

    But I swear it wasn’t like that before the update.

    Plugin Author Chouby

    (@chouby)

    Do you remember what was the previous version?

    Thread Starter nac_87

    (@nac_87)

    not sure, but I updated last time probably 1 month ago

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problems with wp_query code after update to 1.4.3’ is closed to new replies.