Currently, the english version is showing the spanish posts: http://hushmagazine.ca/
Plugin Author
Chouby
(@chouby)
What is your current query?
Hi Chouby, good timing as I was just working on the code. I had just added some new code that I found here:
http://wordpress.org/support/topic/plugin-polylang-translation-with-aggregate-from-elegantthemes?replies=11
I used yoyurec’s suggestion but it seems to have broken up things on the website.
I could really use a suggestion 🙂
// display English menu
if ('en_CA' == get_locale()) {
$args = array( 'numberposts' => 4, 'post_status'=>"publish", 'lang' => 'en_CA', 'post_type'=>"post",'orderby'=>"post_date",'order'=> 'DESC','tag'=>"Feature",'category__not_in'=> array(19,27,454)); // Social Calendar, Contests, Events
}
// display Spanish menu
else if ('es_ES' == get_locale()) {
$args = array( 'numberposts' => 4, 'post_status'=>"publish", 'lang' => 'es_ES', 'post_type'=>"post",'orderby'=>"post_date",'order'=> 'DESC','tag'=>"Feature",'category__not_in'=> array(19,27,454)); // Social Calendar, Contests, Events
}
it looks like ‘lang’ => ‘en_CA’ part is not loading anything into the array. is this code still correct?
I took the code out temporarily as it was messing up the page.
Plugin Author
Chouby
(@chouby)
A lot of things have changed since that time. And for example, Polylang is now capable in most case to automatically translate a query to the current language. So here just remove the ‘lang’ parameter and it should work provided that you translated the tag ‘feature’, you translated the categories (19,27,454) and there are translated posts which match your query.
Moreover when using ‘lang’ in a query you must use the language code (‘en’ or ‘es’) and not the locale
Ah I didn’t try just that! Let me do it now, that would be amazing if it worked that way.
Doesn’t seem to work, you can see that the page is displaying one spanish post still. I took out the ‘lang’ part. Maybe I should try it with that part of the code.
For the posts under the carousel slide, I’m using this code:
// display English menu
if ('en_CA' == get_locale()) {
$args = array('offset'=> 4, 'numberposts' => 10, 'post_status'=>"publish",'post_type'=>"post",'order'=> 'DESC','orderby'=>"post_date",'post__not_in'=> $not_duplicate, 'category__not_in'=> array(19,27,454));
}
// display Spanish menu
else if ('es_ES' == get_locale()) {
$args = array('offset'=> 4, 'numberposts' => 10, 'post_status'=>"publish", 'post_type'=>"post",'order'=> 'DESC','orderby'=>"post_date",'post__not_in'=> $not_duplicate, 'category__not_in'=> array(19,27,454)); // Social Calendar, Contests, Events
}
I added ‘lang’ => ‘en’, and ‘lang’ => ‘es’ on top and that seems to work!
Thanks again Chouby!
Actually, I have one more question, would this be the right code for this function:
wpp_get_mostpopular("post_type='post'&range='monthly'&stats_comments=0&stats_date=1&stats_category=1&limit=6&lang=en");
I added ‘&lang=en’ at the end it doesn’t seem to be working
Plugin Author
Chouby
(@chouby)
I guess wpp_get_mostpopular is coming from a plugin or a theme. So it much depends if it is supporting custom taxonomies in the query or not (as the language is a custom taxonomy).
I see, I’ll check with them. Thanks Chouby!
Hi Chouby,
I haven’t heard from the developer of the plugin yet.
I do see in the code that the plugin supports some qTrans plugin.
I am learning about hooking and filtering, I’m imagining that’s one thing I’d need to do to add this functionality.. ? Do you think this would be at least possible?
Any suggestions would be great, I think this is the only thing that’s left to get everything functioning great with polylang.
Thanks again.
Hi Chouby
I just thought I’d check in again about this. Do you have any thoughts on what users of Polylang use to track most popular posts?
This could be a new thread even, should I post one and see if I hear from the Polylang community?
Thanks!