Sorry my bad, after an update I found out that the plugins has already support WPML, but there’re small bug which will show posts from other languages if there’re no respective post in the current languages.
Line ~1738
$current_id = icl_object_id( $p->id, get_post_type( $p->id ), true, ICL_LANGUAGE_CODE );
change true to false
Hi there,
That’s not a bug. Actually, it’s intended to be that way. If a post / page has been translated into the current language or not falls outside the scope of WPP.
Also, setting the third parameter –return_original_if_missing– to false will have icl_object_id() return NULL (see WPML’s icl_object_id() documentation for more). This will make WPP add a LI element without a post title in the case the current post in the iteration has no translation available – which is not what I’d like to happen.
Hello,
There is also one “error” for WPML support line 1289, in the __update_views() function:
If no posts was created in the original/default language, the var $id = 0 so the function inserts 0 for postid in the WPP tables.
I think the line should be:
$id = icl_object_id( $id, get_post_type( $id ), true, $sitepress->get_default_language() );
I’ve changed “false” by “true” so the post ID in the language of creation is inserted instead of “0”.
The other “problem” I’ve detected, but it’s maybe only related to my website, is that the code suggested by kuongcomputer above for the __render_popular_post() function doesn’t work for me, because ICL_LANGUAGE_CODE constant is always returning the default language…
After searching in vain, I think it’s maybe a problem of plugins loading order or ajax function call… I’m stuck now. If you have any idea why this constant is not set has it should (it’s ok on front but not in the WPP function), I’m listening!
The consequence of this is that the widget displays posts in the default language even if current language is not the default one.
And thanks for your time and module
There is also one “error” for WPML support line 1289, in the __update_views() function:
If no posts was created in the original/default language, the var $id = 0 so the function inserts 0 for postid in the WPP tables.
I think the line should be:
$id = icl_object_id( $id, get_post_type( $id ), true, $sitepress->get_default_language() );
I’ve changed “false” by “true” so the post ID in the language of creation is inserted instead of “0”.
You’re right, somehow I overlooked that. Thanks for the notice, it’ll be fixed soon.
The other “problem” I’ve detected, but it’s maybe only related to my website, is that the code suggested by kuongcomputer above for the __render_popular_post() function doesn’t work for me, because ICL_LANGUAGE_CODE constant is always returning the default language…
…
The consequence of this is that the widget displays posts in the default language even if current language is not the default one.
I’ll take a look into this and reply back as soon as I can.
Hi @anou!
Just checked your report about the ICL_LANGUAGE_CODE constant always returning the default language, and I’m unable to replicate the problem here (see screen capture). Posts and pages are being translated correctly as well, even with the Ajaxify widget feature enabled.
Hello,
thanks for your answers, but I finally found that I must disabled the “Ajaxify widget:” option in order to have the right ICL_LANGUAGE_CODE constant.
If enabled, the constant always returns the default language.
So maybe the only difference between us, is that your are testing on localhost and me on a live website…
I will keep digging…
Thanks again.
So maybe the only difference between us, is that your are testing on localhost and me on a live website…
That shouldn’t make any difference, since the plugin uses the exact same function top build the popular list (and actually the AJAX version runs after everything’s loaded, so it should pick up the current language just fine).
Could maybe a third party plugin be causing a conflict with WPML? Have you tried disabling all of your plugins (except WPP) already?