Why does copying and pasting content into WordPress go wrong?
One of the most common support requests that we get is when a client has been adding content to their site and when they view it on the front-end it just looks…weird.
There can be any number of strange things wrong with it, but usually, there are layout issues, for example, the text being constrained in a narrow box.
The cause of this is often markup (HTML code) that has been copied along with all of your text.
This is often in the form of wrapper
<divs> around your content that sometimes have layout rules applied to them.
For example, you might copy the following text into the editor:
This looks fine, right?
But when you switch from the ‘Visual’ to the ‘Text’ view, you can see the problem:
Now you can see, as well as the text that we wanted, we’ve also copied all of the original markup into our new post.
So, how can we copy and paste content from a website without also copying all of the additional markup? There are three techniques that I know of but before you use them, read to the end because there’s a caveat!
1. Paste directly into the 'Text' view
The first method is probably the easiest.
- Copy the content from the web page.
- Click on the ‘Text’ tab in the editor.
- Paste your content.
This will automatically paste the content as plain text and without ANY (this is important) markup.
2. Use CMD/CTRL + Shift + V
If you don’t want to have to click over to the ‘Text’ view in the editor you can hold down ‘Shift’ while pasting your content.
(I haven’t tested this on Windows, but I assume that CTRL + Shift + V does the same thing)
3. Use the 'Paste as text' button
WordPress has been around for a long time, so it’s seen and solved a lot of these problems already – and this is no exception.
While on the ‘Visual’ editor view, click on the ‘Toolbar toggle’ button and then on the ‘Paste as text’ button.
Now when you paste your text into the ‘Visual’ view all of the formatting will be removed.
But where have my links, titles, lists, etc gone?!
There’s a big caveat to these three techniques – they will strip out ALL of your markup – even the stuff that you might want to keep.
Only the text will remain.
This means that headings, links, lists, bold text, etc will all have been removed and you will need to add again.
So far, I don’t have a good workaround for this. It’s either a choice of:
- Removing all of the redundant formatting manually, in the ‘Text’ view
- Pasting the content without formatting and then adding it back in
If anyone has a better way I’d love to hear about it.