This thread is resolved. Here is a description of the problem and solution.
Problem:
The client needed a solution for inserting different affiliate codes for each language in their posts without losing changes after updates or re-translations. The affiliate codes were not appearing in the ATE translator as regular text links, and manual replacements were being overwritten with updates.
Solution:
We recommended using a custom PHP snippet or shortcode that dynamically inserts the affiliate code based on the current language. This approach ensures that the correct widget appears automatically for each language version and remains unchanged after updates or re-translations. Here is an example of how you might set this up:
function cityxee_viator_widget() {<br /> if (defined('ICL_LANGUAGE_CODE')) {<br /> switch (ICL_LANGUAGE_CODE) {<br /> case 'da':<br /> return 'kode til dansk viator';<br /> case 'en':<br /> return 'kode til engelsk viator';<br /> case 'fr':<br /> return 'kode til fransk viator';<br /> }<br /> }<br />}<br />add_shortcode('cityxee_viator', 'cityxee_viator_widget');For posts requiring unique codes, we suggested using a custom field to store the affiliate ID, which can then be dynamically inserted into the affiliate widget code for each post:
<?php<br />$idkey = get_field('acf_partner_id'); // or whatever your field name is<br />?><br /><div data-vi-partner-id="<?php echo esc_attr($idkey); ?>" data-vi-widget-ref="W-6712b6be-d928-47db-b9a6-c96bce812859"></div><br /><script async src="https://www.viator.com/orion/partner/widget.js"></script>If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.
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.
This topic is split from https://wpml.org/forums/topic/automatic-translations-keeps-stuck/
This topic contains 5 replies, has 0 voices.
Last updated by 2 months, 3 weeks ago.
Assisted by: Dražen.