Display HTML Code in WordPress Post
In WordPress posts if we write any HTML codes in Text editor, the code will not be displayed.
Instead of code, WordPress, sends the HTML code as it is.
The web browser compiles the code to display its output. Hence the code will not visible to the reader.
To avoid this, follow these steps
- Write code in visual editor.
- Select the code.
- Change format to ‘preformatted’
So, the web browser does not compile it and the output will display the code as it is.
Decode HTML Tags for Pre/Code
The alternate method is to use online HTML decode services available. Google for HTML decode and you will get many matching online decoders. Then follow these steps.
- Get it decoded.
- Copy the resulting HTML code.
- Paste it in text editor.
- Wrap it with <pre> tag
External Reference: Stackoverflow discussion on same topic.