cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
280 stars 82 forks source link

wpp_custom_html not working with WPML different languages #296

Closed jopeek closed 2 years ago

jopeek commented 2 years ago

I used the sample code for the custom html output for the WPP from https://github.com/cabrerahector/wordpress-popular-posts/wiki/3.-Filters#wpp_custom_html, and while it works great, it does not display the title of the post in the appropriate language (from WPML). It does show the correct url, but not the title. If I use the stock output code instead of wpp_custom_html, it shows the proper title. Is there something I can tweak in the wpp_custom_html sample code to get it to use the title from the current language?

cabrerahector commented 2 years ago

Yep, the wpp_custom_html filter hook assumes that the developer (you in this case) will do everything related to the front-end, including integration with third-party plugins like WPML.

When using the stock HTML output WPP translates texts & URLs via the Translate class before rendering the popular posts list on screen.

Have a look at the Output class to see exactly how the plugin uses this class to translate posts, and if you have any questions feel free to ask.

jopeek commented 2 years ago

Perfect, thank you!