Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 4 replies, has 1 voice.

Last updated by Marcel 2 months, 1 week ago.

Assisted by: Marcel.

Author Posts
November 12, 2025 at 3:47 am #17568588

erikaR-3

Background of the issue:
I am developing a site and using WPML to manage translations. I have a Custom Post Type called 'Wiki Articles' and a custom plugin for a chained quiz. I followed online instructions to enable translations for the Custom Post Type. My site is currently private but can be made public for troubleshooting.

Symptoms:
There are duplicate posts displaying on the front end for the 'Wiki Articles' Custom Post Type, showing both English and Spanish articles regardless of the language selected. Additionally, my custom plugin translates buttons but not the questions or other text.

Questions:
How can I fix the issue of duplicate posts displaying for my Custom Post Type 'Wiki Articles'?
What is the correct way to translate all text in my custom plugin, including questions and other text?

November 12, 2025 at 4:01 am #17568625

erikaR-3

Would love help figuring out how to translate my custom quiz plguin. Some strings are translated, but not the strings in my quiz-template.php file.
You can see this quiz displayed here: hidden link

November 12, 2025 at 3:05 pm #17571539

Marcel
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Hi,

Could you please upload the specific code of this plugin to http://www.pastebin.com
(or any similar service) so I can take a look at it?

However, please note that custom coding is not part of our support policy, so I may only be able to guide you toward a possible solution rather than provide a full code fix.

Thank you!

Best regards,
Marcel

November 12, 2025 at 7:57 pm #17572721

erikaR-3

Hi Marcel,

Thanks, here is the main php:
https://pastebin.com/K5tVqPz3

Here is the JS:
https://pastebin.com/tLbiqUi2

Here is the template file:
https://pastebin.com/55Dx7FAt

November 13, 2025 at 12:05 pm #17574704

Marcel
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: Europe/Madrid (GMT+02:00)

Thanks! In the template, all static texts are already correctly wrapped in gettext calls and associated with the text domain wikipersona-quiz. These strings can be scanned in WPML → Theme & Plugin Localization and then translated via WPML String Translation.

However, the quiz logic currently has two copies of all text:
one in PHP and another hard-coded inside the JavaScript file. WPML can only translate strings that originate in PHP, so the content stored inside script.js will never be translated.

To make the plugin fully compatible with WPML, all quiz text (personas, questions, and options) must be moved out of the JavaScript file. The correct approach is to define and translate all text in PHP, then pass the translated data into the JavaScript using wp_localize_script(). The JS file should no longer contain any hard-coded English strings—only the data coming from PHP.

I recommend hiring a developer to update the plugin structure, so all user-facing text is properly prepared for localization.

Best regards,
Marcel