A customer asked to implement a third-party service on his website under our site management (in this case it is Fidelo).
By inserting the scripts provided by this software, when you then publish the page and check with the console, the script appears changed with the addition of the parameter “&%3B
” in place of the original “&” present in the provided script.
This small change does not allow the optimal execution of the script provided on the web page.
In this article we provide the solution we have implemented
&%3B
?The parameter “&%3B
” often appears in URL links due to incorrect character encoding “&
“. To remove it from a script, you need to decode the URL and remove the unwanted parameter.
Here are the steps to do it in JavaScript:
decodeURIComponent()
to transform the encoded URL into readable format.Here is an example script:
// Let's assume this is the URL with the wrong parameter
let url = "https://example.com?param1=value1&%3Bparam2=value2";
// Decode URL
let decodedUrl = decodeURIComponent(url);
// Remove 'amp;' and replace it with the correct '&' symbol
let cleanedUrl = decodedUrl.replace("amp;", "&");
// Final output of the clean URL
console.log(cleanedUrl);
This script:
amp3b
, ripristinando il simbolo &
nella posizione corretta.amp%3B
in WordPressTo remove &%3B
from a URL in WordPress, you can follow different paths depending on where the problem arises. Here are some common solutions:
functions.php
You can add a function in your theme’s functions.php file to remove or fix the parameter &%3B
from URLs.
Here’s an example of code that decodes the URL and removes it &%3B
before it’s displayed:
// Add this function to your theme's functions.php
function clean_amp_param($url) {
// Decode the URL
$decoded_url = urldecode($url);
// Remove 'amp;' and replace it with '&'
$cleaned_url = str_replace('amp;', '&', $decoded_url);
return $cleaned_url;
}
// Apply the function to URLs generated by WordPress
add_filter('the_permalink', 'clean_amp_param');
add_filter('wp_get_attachment_url', 'clean_amp_param');
This function:
urldecode()
.amp;
with the correct symbol &
.the_permalink
and wp_get_attachment_url
to apply it to URLs generated by WordPress.If you don’t want to edit your theme files directly, you can use a plugin like “ Code Snippets ” to easily add PHP code without editing the functions.php
.
If the error &%3B
appears in links within your site content (like posts or pages), they may have been added manually or generated by shortcodes or plugins. You can do the following:
&%3B
and replace it with &
.If you are using a plugin that handles AMP pages, check your plugin settings or update the plugin itself, as this could be the source of the problem.
Sometimes this type of error can be caused by caching or a CDN manipulating URLs. Make sure to clear your WordPress cache and if you use a CDN, check for problematic rewrite rules.
We will send you periodical important communications and news about the digital world. You can unsubscribe at any time by clicking the appropriate link at the bottom of the newsletter.
The November 2024 update brings new challenges for content creators. Here are some tips for…
From language learning to writing, AI offers useful tools to improve study effectiveness Artificial Intelligence:…
The world of marketing is constantly evolving, and with the advent of digital technology, Search Engine…
Switch to Bing and win up to $1 million! Microsoft launches an initiative to encourage…
Google has announced a breakthrough in cybersecurity: Big Sleep AI discovers a bug in the SQLite database.…
AI is reshaping software development, with engineers now focusing on review and innovation. AI now…