Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Raw Codes in Your WordPress Blog Posts

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display Raw Codes in Your WordPress Blog Posts

WordPress while being a great software sometimes have its shortcomings. One of them is that it executes every code that you insert in your blogpost. While that is an excellent feature, it sometimes become a problem for those users who are writing a tutorial that requires them to give their users the HTML or PHP code in the post for their audiences to copy and paste. For example if you want to show your audience, how to italicize a text in WordPress, you will ask them to use <em>, but if you put it like that then it will end up italicizing a text, and not showing your users the code.

In this article we will show you how to display raw codes in your WordPress blog posts, so your users can not only see it, but copy and paste it if necessary.

First thing you need to do is write the code, the way you would normally write it. For example if we ask you guys to link to us and give you a code, it should look like:

<a href="" target="_blank">WPBeginner</a>

Then you will need to head over to one of the tools on the web that can encode the HTML tags such as Postable or HTML Encoder. Paste your code in their input box and encode it, or in other words make it friendly. Once you encode, your code should look something like:

&lt ;a href=" ; target=&quot ;_blank&quot ;&gt ;WPBeginner&lt ;/a&gt ;

If you don’t use these tools that are mentioned above and post the tag normally, WordPress will execute your code:


You may surround the codes with a <code> tag to have a more noticeable css styling, or any other css class of your choosing.

Now you can display Raw Codes in Your WordPress Blog Posts.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Hannah says:

    Just what I was looking for! Thanks!

  2. Leanne Schmidt says:

    Thank you it is so easy! But what if you want to use it in a widget?
    If I add it to a text widget then it cuts half of the code off…

  3. andrean says:

    been long time wondering how to do so

  4. Michael Soriano says:

    syntax highlighter is also a good option

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.