When you want to write and article and add HTML code to your WordPress post it does not always work they way you intended. What you want to do is show HTML code but not have it act like code. This is really annoying when you paste code into your article draft, even into the HTML section, and the code does not show up for you. Even if it does show up it might look different to what it is meant to be.
It’s no big deal though and this problem can be easily fixed. I will show you how to add HTML code or even php code into your WordPress posts.
Not all code gets distorted so it depends on the code you use. You can simply see this by trying to paste the code into your post draft. If it looks a bit weird then follow my instructions below.
Add HTML code to your WordPress Posts
Before pasting your HTML code into your WordPress post, you will need to convert it to text. You can do this by visiting this website. It has a handy tool that will convert HTML code to text for you.
- Copy your HTML from the source by selecting it and right clicking on it to choose copy from the menu.
- Paste the code into the box.
- Press on the HTML to text button.
- Copy the changed code and bring it back to your WordPress post.
- Now post the code into your HTML section and it will not act like HTML. It will be text written to look like HTML when viewed.
The code will be transformed into text equivalents which are called character entities.
Here is a list of the most common HTML character entities:
< = <
> = >
/ = /
] = ]
[ = [
” = "
‘ = '
For example the code above looks like this in the HTML section of this post
< = &lt;
> = &gt;
/ = &#47;
] = &#93;
[ = &#91;
” = &#34;
‘ = &#39;
But shows up different on the actual post.
Other ways to add code to a WordPress post
There are many ways to add code to a WordPress post without having the code ruined and changed. You might want to install a WordPress plugin if you add code all of the time. There are other ways to add code to your WordPress post but the way I have shown you above is far less technical.