Recently I was trying to create a link from one page to a specific subheading on another page, called an anchor link. The goal was to link half way down the page to a certain topic instead of the top a page, the way links usually work.
When I tested the link numbers, letters and the % symbol
How do you stop WordPress from inserting extra random characters into link URLs on your website? If you copied the link from the permalink editor or somewhere else in the admin dashboard retype the link instead of copying it. Copying text can sometimes pick up encoding that you can’t see but the browser will try to interpret when the link is clicked.
Everything looked fine in the WordPress link editor but when I followed the link the characters %E2%80%8E were inserted into the URL and I was given a 404 page not found error.
I tried numerous unsuccessful fixes that included clearing my site cache, deleting the browser cache, updating plugins and deleting and recreating the link. Nothing worked.
What causes it?
This can sometimes happen when you copy text from a word processor like Microsoft Word or when you copy links that aren’t in plain text like I did.
Every time I recreated the link I was pasting the same URL not realizing there was some kind of encoding in it. I had originally copied the URL from the permalink section of the post editor. Which it turns out isn’t just plain text, there is some encoding included when you copy text from there that isn’t visible when you paste the URL into the WordPress link editor.
How do you fix it?
Retype the link.
Eventually I decided to retype the link instead of using copy and paste. That fixed the problem. In hindsight it should have been the first thing I tried, but I had never experienced that before in all my time of copying and pasting URLs for links.
The extra characters added to your URL might not be %E2%80%8E, but if you see something similar, chances are there is some invisible encoding that needs to be removed.