 vitaliiO
|
I've created 2 new pages: test-page-1 and test-page-2. Did all the steps and the link still points to main language. Link in previous message is acf link field, which is children of block, that is childern of Flexible Content
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
Hi,
I would like to offer to take a closer look and request temporary access (wp-admin and FTP) to the site to investigate the issue further.
The required fields are below the comment section when you log in to leave the next reply. The information you provide is private, meaning only you and I can see and access it.
IMPORTANT
Please be sure to back up the site and database before granting us access.
If you can't see the "wp-admin / FTP" fields, your post and site login details will be set to "PUBLIC". DO NOT publish the data unless you see the required wp-admin / FTP fields.
The private reply form looks like this:
hidden link
The next time you reply, click on "I still need assistance".
Video:
hidden link
Please note that we are obliged to request this information individually on each ticket. We are not allowed to access any credentials that were not specifically submitted on this ticket in the private response form.
Best regards
Andreas
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
Your field groups are not configured correctly.
Repeater Fields, Groups, and Flexible content fields need to be set to "Copy once" or "Copy".
All your fields are set to "Not translate".
As long as a field is set to "Not translate", nothing will happen if you translate the page. You need to set the link fields to "Copy" to copy the link or to "Translate" to translate the link.
Please follow this guide to set up the fields:
https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/
Copy > The field value will be copied every time you translate content
Copy once > The field value will only be copied once (use this only if you translate posts or pages with the WordPress Editor)
Translate > The field will be available inside the translation editor for translation
After making changes to the fields you will need to edit the fields again on the original page, save the page, and then open the translation editor.
|
 vitaliiO
|
Hello,
Here’s what I did:
1. Set a "Flexible Content" field to "Copy".
2. Within the "Stats Banner" (a flexible content block), the "Colour Box" group and the "link" field inside it were set to "Copy".
3. Created a new page: "weekend-test-page" (hidden link) and translated it.
4. Created another page: "weekend-test-page-2"(hidden link), added the "Stats Banner" block, and selected the first page in the "link" field.
5. Saved the changes.
6. Created a translation for the second page using the Advanced Translation Editor. The "link" field did not appear in the editor, which is expected based on your previous explanation:
"This is why the link field is set to 'Copy' by default and does not appear in the WPML Translation Editor. In this case, it should automatically use the translated URL if the linked page is translated and published."
So I expected the link to the first page to be automatically changed to the French version after translation.
However, after translation, the link still points to the original language version instead of the translated one.
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
We do have a known issue for this use case which is already escalate to our development team.
Please take a backup of your site incl. database and try to apply the following workaround:
Workaround
Edit wp-content\plugins\acfml\classes\class-wpml-acf-blocks.php go to line 191 and replace
private function get_text_type( $text ) {
$type = 'LINE';
if ( is_array( $text ) ) {
$type = 'array';
} elseif ( strip_tags( $text ) !== $text ) {
$type = 'VISUAL';
} elseif ( strpos( $text, "\n" ) !== false ) {
$type = 'AREA';
}
return $type;
}
with
private function get_text_type( $text ) {
$type = 'LINE';
if ( is_array( $text ) ) {
$type = 'array';
} elseif ( strip_tags( $text ) !== $text ) {
$type = 'VISUAL';
} elseif ( strpos( $text, "\n" ) !== false ) {
$type = 'AREA';
} else if (preg_match('/^(?:https?):\/\/\S+/i', $text)) {
$type = 'LINK';
}
return $type;
}
|
 vitaliiO
|
I've made changes to this file:
dev.polarisagency.com/wp-content/plugins/acfml/classes/class-wpml-acf-blocks.php
You can see the changes in the screenshot.
I repeated all the steps by creating two new pages and adding a link from the second page to the first. However, the link still points to the main language.
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
You are using a version of ACF PRO that was released in November 2023.
Also, WPML and our addons are outdated.
Please update all plugins and then test again.
|
 vitaliiO
|
Hi, I updated the WPML, WPML addons and ACF Pro plugins, created two new pages again, translated them, and the links still point only to the main language.
You can try creating two new pages yourself and following these steps.
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
As you can see on the screenshot, your field group is still not configured correctly.
If you use the "Expert" mode you need to follow this guide:
https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/
If you have doubts about how to set each field, please use the group settings:
- Same fields across languages (for translation with the WPML Translation Editor)
- Different fields across languages (for translation with the WordPress Editor)
|
 vitaliiO
|
Hi, almost all my pages are built using Flexible Content. This is the 'Components Page' field group, as you can see in the screenshot. It seems to be configured correctly. I have properly configured the 'Stats Banner' block, which is a child of Flexible Content. You can check it.
hidden link
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
Thank you for the details.
I went through half of the group and there are various configuration issues. For example, all the Repeater Fields were set to "Translate". They should be set to "Copy".
Now, this is a huge group and I can not go through it all for you.
If you want to save time, and if all your links ar internal links anyways, then please set the field group to "Same fields across languages" and then translate the page again.
This usually should solve the issue.
|
 vitaliiO
|
In fileds group "Components Page" (flexible content) I set Repeater Fields, Groups, and Flexible content fields to "copy".
I created again new pages (hidden link) and built it with "Components Page" (flexible content) blocks.
But the link still points to main language.
|
 Andreas W.
WPML Supporter since 12/2018
Languages:
English (English )
Spanish (Español )
German (Deutsch )
Timezone:
America/Lima (GMT-05:00)
|
Ths issue is inside your template.
Using the following approach solves the issue while keeping links on "copy".
if ($row === 'stats_banner') {
$image = get_sub_field('image');
$src = wp_get_attachment_image_src($image['id'], 'thumb_2000_0');
echo '<div class="stats-banner" style="background-image: url(' . $src[0] . ');" data-colour="dark">';
echo '<div class="stats-banner__content container">';
echo '<div class="stats-banner__stats">';
echo '<div class="stats-banner__left-stat">';
$largeStat = get_sub_field('large_stat');
if ($largeStat) {
echo '<span>' . $largeStat . '</span>';
}
$text = get_sub_field('text');
if ($text) {
echo $text;
}
echo '</div>';
$colourBox = get_sub_field('colour_box');
$firstColour = $colours[$colourBox['colours']['first']];
$secondColour = $colours[$colourBox['colours']['second']];
// Translate the link and title
$link_url = $colourBox['link']['url'];
$link_title = $colourBox['link']['title'];
if ($link_url && $link_title) {
// Translate the URL (if needed), WPML generally handles URLs of translated pages
$translated_link_url = apply_filters('wpml_permalink', $link_url);
// Translate the link title (if the title is a translatable string)
$translated_link_title = apply_filters('wpml_translate_string', $link_title, 'acf', 'link_title_' . $colourBox['link']['title']);
// Output the translated link
echo '<div class="stats-banner__right-stat" style="background: linear-gradient(to right, ' . $firstColour . ' 40%, ' . $secondColour . ' 40%);">';
if ($colourBox['top_text']) {
echo $colourBox['top_text'];
}
if ($colourBox['stat']) {
echo '<span>' . $colourBox['stat'] . '</span>';
}
if ($colourBox['bottom_text']) {
echo $colourBox['bottom_text'];
}
if ($translated_link_url) {
echo '<a href="' . $translated_link_url . '">' . $translated_link_title . '</a>';
}
echo '</div>';
}
echo '</div>';
echo '</div>';
echo '</div>';
}
Using the 'wpml_permalink' hook in your template will make sure that the correct URL will be loaded for each language.
This will automatically adjust the link without the need to translate it. The downside is, that you will not be able to translate the link text, as it is being copied.
To translate the link text, the link field would need to be set to "Translate" but this would include that you also need to translate the links.
|
 vitaliiO
|
Hi,
I fixed some of my templates this way:
$translated_link_url = apply_filters('wpml_permalink', $link['url']);
And it actually changes links by adding "fr".
But there's a problem:
I have a page: hidden link
When using apply_filters('wpml_permalink', $link['url']);, it changes the link to hidden link (see screenshot). This link is located on the page: hidden link.
When I click on it, it opens hidden link instead of hidden link.
This happens because the actual translated page URL is hidden link, not hidden link.
|