If this solution does not resolve your issue or 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 the problem persists, 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.
A published errata means that the case is in development and we'll be publishing any relevant updates on the said errata page.
You can find several errata pages at https://wpml.org/errata/ with different statues like Open, Resolved, Waiting for author and etc. So these're not cold cases, however, may take some time to fix and improve (due to current load of work).
This errata offers temporary solution, which is using manual translation for now. Once you fix the URL by manually translating it, the translation memory 'll help in future translations of the same URL. So practically you'll not need to translate again the same URL.
Unfortunately that's the only way of doing it so far.
Our team suggested the following workaround, which I've tried in your test site and this seem to fix the links problem.
- Take a backup of the site before proceeding.
- Open the app/public/wp-content/themes/betheme/functions/builder/class-mfn-builder-front.php file
- Look for the folloiwng code, around line 2645:
public function show_items($item, $i, $vb, $w_iterate = false){
/*echo '<pre>';
print_r($item);
echo '</pre>';*/
$inner_class = array();
$item_class = array();
- And replace with:
public function show_items($item, $i, $vb, $w_iterate = false){
/*echo '<pre>';
print_r($item);
echo '</pre>';*/
// WPML Workaround for compsupp-7547
if ( class_exists('Sitepress') && isset($item['attr']['content']) && is_string($item['attr']['content']) ) {
// Find the links in the content
$pattern = '/<a\s[^>]*href=["\']([^"\']+)["\']/i';
// Replace with translated URLs
$item['attr']['content'] = preg_replace_callback($pattern, function($matches) {
$original_url = $matches[1];
$wpml_current_lang = apply_filters( 'wpml_current_language', NULL );
$translated_url = apply_filters('wpml_permalink', $original_url, $wpml_current_lang, true);
return str_replace($original_url, $translated_url, $matches[0]);
}, $item['attr']['content']);
}
$inner_class = array();
$item_class = array();
This should be enough to display the translated URLs in the front-end.
Please note that this is more a workaround and not a proper fix, so keep an eye out for any problems that may arise.
Hello,
Thank you for your effort, but Im not much confident into changing php codes, which I then need to replace every time, when BeTheme comes with update.
If I understand corectly, this piece of code bypass automatic link targeting and changes urls in translated pages directly in front end? This looks, like it can bring many problems into the site as whole. I would rather vote for a proper solution.