Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues with WPML automatically translating or altering URLs in your content blocks, particularly for buttons within Gutenberg blocks, this might be due to WPML's default behavior of processing URLs on the fly.
Solution:
We recommend two approaches to prevent WPML from altering your URLs:
1) Add a custom XML configuration to instruct WPML to copy the URL as-is instead of translating it. You can add this configuration directly in your theme or plugin, or through WPML's settings under 'Custom XML-Config'. Here's an example of what your configuration might look like:

<wpml-config> <gutenberg-blocks>   <gutenberg-block type="your/block-name">      <key name="url" action="copy"></key></gutenberg-block> </gutenberg-blocks></wpml-config>

Make sure to replace 'your/block-name' with the actual name of your block and 'url' with the attribute key.
2) Disable WPML's link rewriting during rendering by adding a filter in your theme's functions.php file:

add_filter('wpml_translate_link_targets', '__return_false');

Alternatively, for a more aggressive approach:

add_filter('wpml_permalink', function($url) { return $url; });

If these solutions do not resolve your issue, or if they seem outdated or irrelevant to your specific case, 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.

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 1 replies, has 0 voices.

Last updated by Marcel 1 month, 2 weeks ago.

Assisted by: Marcel.

Author Posts
March 31, 2026 at 12:03 pm #17939890

pietR-2

For a page i have content blocks. In those content block is a button with a link. This link is getting picked up by wpml and changed on the fly. I don't want that.

My code:

//Register ACF block

acf_register_block_type([
'name' => GutenbergBlock::CONTENT_BLOCK_WITH_SHORTCODE,
'title' => __('Content block & shortcode'),
'description' => __('Displays content block with shortcode & image.'),
'render_callback' => [$this, 'renderContentBlockWithShortCode'],
'category' => static::CATEGORY_exampleERVICE,
'icon' => 'shortcode',
'keywords' => $this->getKeyWords(['content', 'block', 'text', 'image', 'shortcode']),
'enqueue_assets' => function () {
if (is_admin()) {
wp_enqueue_style('example-editor-style', get_template_directory_uri() . 'https://cdn.wpml.org/example-editor.css');
}
}
]);

// Render template

public function renderContentBlockWithShortCode($block) {
get_template_part('partials/gutenberg/content-block-with-shortcode', args: ['block' => $block]);
}

// Template (partial)

<?php $category = get_field(ACFField::GUTENBERG_CONTENT_BLOCK_ACTION); ?>
<?php if($category instanceof WP_Term): ?>
<div class="button-wrapper">
<?php $categoryUrl = get_term_link($category, Taxonomy::PRODUCT_CATEGORY); ?>
hidden link
</div>
<?php endif; ?>

// Debugging

Url in template is:

$categoryUrl = "hidden link"

Url in browser is:

April 2, 2026 at 8:56 am #17945262

Marcel
Supporter

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

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

Hi,

yes, it's the default expected behaviour that WPML tries to “translate” or process the URL inside the block attributes. I woudl recommend two ways to change it:

1) Prevent WPML from translating the URL:

If the URL is stored as a block attribute, you can tell WPML to copy it as-is instead of translating it.

Add a wpml-config.xml file to your theme or plugin or add it on WPML -> Settings -> Custom XML-Config:
Example:

<wpml-config>
  <gutenberg-blocks>
    <gutenberg-block type="your/block-name">
      <key name="url" action="copy" />
    </gutenberg-block>
  </gutenberg-blocks>
</wpml-config>

Replace:

your/block-name with your actual block name and the URL with the attribute key

This will prevent WPML from touching the URL at all, which usually fixes the issue completely.

2) Disable WPML link rewriting via filter

If the issue is caused during rendering (e.g. WPML rewriting links), you can disable that behavior with a filter:

add_filter('wpml_translate_link_targets', '__return_false');

Or more aggressively, if needed

add_filter('wpml_permalink', function($url) {
    return $url;
});

Best Regards,
Marcel