This thread is resolved. Here is a description of the problem and solution.
Problem:
The client needed to change and translate a URL in the PHP code from the
functions.php
file, specifically within an action hook that outputs a contact button.
Solution:
We recommended using the gettext function to make the string translatable. We provided step-by-step instructions:
1. Replace the hardcoded URL in the PHP code with the
__()
function and include the text domain.
2. Rescan the theme for strings using WPML's String Translation.
3. Translate the URL in WPML > String Translation.
Here is the modified code snippet:
add_action('ava_main_header', function() { $output = __("<div class='av-cta-button av-desktop-hid av-tablet-hide av-button'><a href='https://outdoorpsycholoogleiden.nl/contact/'>Contact</a></div>", "your-text-domain"); echo $output; }, 10);
For more information, we provided links to the relevant documentation:
- Understanding gettext, text domains, and domain paths
- I18n for WordPress Developers
- How to scan the theme or plugin for strings
If this solution does not apply to your case, or if it seems outdated, we encourage you to open a new support ticket. We also highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. For further assistance, please visit our 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 contains 1 reply, has 2 voices.
Last updated by 1 year, 4 months ago.
Assisted by: Mihai Apetrei.