Problem with WPP and WPML
-
Hello,
These are the details of my configuration :
– WordPress Version 4.9.6
– WPP Version 4.1.0
– WPML Multilingual CMS Version 3.9.4, where default language is French and additional language is English.The description of the plugin WordPress Popular Posts, says that it is compatible with WPML but i can’t see how it is compatible. The problem is the posts in the english site are not showing at all, even if they aren’t a translation of french posts.
The other problem is that the posts translated in english aren’t counted as views and don’t increase the views of the original posts as said here.
-
Hi @djallel,
From the description:
Polylang & WPML 3.2+ support – Show the translated version of your popular posts!
Basically, the plugin will list the most viewed / most commented posts on your site. If the current language is french, the plugin will list the original articles. If the current language is english, the plugin will display their english translation instead. If a post doesn’t have a translation available (either in french or in english) the original version will be displayed instead.
Hope that clarifies things a bit.
Thank you for your quick response.
That’s what i was expecting when i installed the plugin, but i guess there is an issue somewhere because this is not the result i’m getting.
As i said above, only the the french posts are displayed, even it the chosen language of the website is English, even if a translation is available for those posts. Adding to that, the views of the translated posts are not counted for the original post.
That’s odd. I’ll try installing WPML again (although I think I have an older version of the plugin) and do some tests. I may need some additional info from you or even your help, if so I’ll let you know.
Ok i’ll be in touch.
Thank you1.Hey @djallel,
I’ll try installing WPML again (although I think I have an older version of the plugin) and do some tests.
Unfortunately I lost the copy I had of the WPML plugin, and I no longer have access to a valid license either.
Is there any chance you could provide a copy of the WPML plugin?
@hcabrera The user posted a link to download the plugin. As that’s a commercial plugin I removed it.
Please post a contact URL that the user can then provide you that link.
Thanks Jan. I really wasn’t expecting the OP to post a download link, should’ve been more explicit.
@djallel please get in touch with me.
Hey @djallel,
I just set up a test site with WPML 3.9.4 and WPP. English is the main language, Spanish the secondary one. Twenty Seventeen is the active theme. Latest WordPress version. The only active plugins are WordPress Popular Posts (latest version available), WPML, and Markus Fischbacher’s Log Viewer (to check the debug.log file for PHP warning / error messages).
I created four posts (6 actually if we include the translations):
- Two of them are in english and have their corresponding spanish translations;
- One of them is only available in english, no spanish translation;
- The remaining one is in spanish, no english version.
For this test I added the language switcher widget from WPML to the sidebar, and right below it the WPP widget.
After viewing all of the posts at least once, here’s the result:

As you can see, WPP correctly detects the currently active language and the popular posts list gets updated accordingly.
Also, as I mentioned above, if a given post doesn’t have a translation available in the currently active language WPP will display the original version instead.
If this isn’t the behavior you’re seeing on your site, something else -as evident as this might sound- is causing a conflict. It could be either one of your plugins or something on your current theme.
Try this:
- Switch for a moment to another theme. Is the issue still present? If so, then the problem is likely being caused by one of your plugins. Disable them (except for WPP), enable one of the plugins and check your site again. Repeat until the issue reappears and you’ll find out which plugin is causing it.
- If the problem is gone after switching to a different theme, then it’s your theme.
Give that a shot and let me know how it goes, alright?
Hello again @hector,
I think i figured it out why the views on my english posts aren’t counted, i found out that an error was firing in the browser console log, which is the following :
POST http://localhost/wordpresslab/wp-json/?lang=en/wordpress-popular-posts/v1/popular-posts/ 404 (Not Found)i think there is something to be done about the ?lang=en par of the url, it is added automatically in the english version of the website.
also i found one small possible mistake in the WPP_Output class, in the method get_excerpt :
$excerpt = ( empty($the_post->post_excerpt) ) ? $the_post->post_content : $post_object->post_excerpt;I think it was meant to be :
$excerpt = ( empty($the_post->post_excerpt) ) ? $the_post->post_content : $the_post->post_excerpt;i think there is something to be done about the ?lang=en par of the url, it is added automatically in the english version of the website.
Yes, that’s exactly the problem. Nice catch!
When I set up WPML on my test site, I changed Language URL format from the default “Language name added as a parameter” to “Different languages in directories” and everything worked normally. Leaving the default option on does indeed break WPP’s ability to register post/page views if:
- Language URL format is set to “Language name added as a parameter”, and
- You’re using a custom Permalink structure (curiously, using the ugly Plain permalink option doesn’t break it).
So you either need to set Language URL format to any option but the default one, or you set WordPress to use the Plain permalink structure instead (eg. https://www.example.com/?p=5&lang=en).
also i found one small possible mistake in the WPP_Output class, in the method get_excerpt
Indeed, that doesn’t seem right! Thanks for pointing that out, I’ll have a look into it ASAP.
Update: fixed it!
Already did, and it works.
Just wondering why this was the problem, was the js library called using the actual url ?WPP -as you already noticed- relies on the REST API to pass/get data to/from WordPress.
When the plugin requests the URL of the REST API, for some reason WPML’s
langparameter gets appended in the wrong place (parameters are supossed to be at the end of the base URL), triggering the 404 error you saw as WordPress didn’t recognize that URL as a valid one.Why does this happen? No idea, to be honest. Not sure if it’s a WordPress bug, a WPML bug, or a WPP bug. If it’s the latter I’ll make sure to fix it.
Okey, thank you very much for your help.
It is now marked as resolved.
The topic ‘Problem with WPP and WPML’ is closed to new replies.