Raw HTML Plugin for WordPress

Introduction

Recently I needed to put some style definitions and a JavaScript function in a post on another blog that I have. I wasted several hours trying to do this, because WordPress insisted on putting backslashes in front of my apostrophes, inserting superfluous <p> or <br /> tags in place of newlines, and generally breaking my HTML in various horrible ways.

In the end I decided to just go and write a plugin that would let me disable the automatic formatting that WordPress applies to post content. This plugin adds a set of shortcodes that you can use to “protect” specific parts of your post and prevent WP from messing with them.

Download & Installation

Requirements :

  • WordPress 2.8 or later
  • If you use the free version, I strongly recommend disabling the visual editor. It (the editor) can mess up your code even if you use this plugin.

Installation is straightforward – download the zip file, unzip, upload the raw-html folder to /wp-content/plugins and activate it in the Plugins tab.

Usage

There are two ways to use the plugin. First, to turn off “smart quotes” and other built-in filters for an entire post, use the checkboxes that Raw HTML adds to the “Edit Post” screen:

Raw HTML meta box screenshot

If you want to prevent a specific part of your post or page from being processed and “texturized” by WordPress, wrap it in ... or <!–raw–>…<!–/raw–> tags. The two versions work exactly the same, with one exception – the <!–raw–>’s won’t be visible to your visitors even if you deactivate the plugin.

Example :
<!--raw-->
This

is

a ‘test’!
<!–/raw–>

Result :
This is a 'test'!

If you view the source code of this page, you will see that the newlines are still there, and the apostrophes haven’t been converted/escaped.

Other Notes

This plugin is provided AS IS, with no guarantee that it will work on your site.

Related posts :

315 Responses to “Raw HTML Plugin for WordPress”

  1. Chat4smile says:

    Hi,

    just want to say thanks about info that you have shared keep up the good work i really appreciate your effort thanks again

  2. Michael says:

    Thanks so much for this amazing plugin. Is it possible to change the default setting of having the checkmark selected for disabling automatic paragraphs?

  3. Michael says:

    I figured it out. For anyone else if you open the screen options, you can select which options will be ticked of by default.

  4. Martin Lacher says:

    It just doesn’t work. 🙁 I’m using WordPress 5.5 and RAW 1.6.3 which is supposed to work 100%. I’m editing a page with Elementor. When I’m adding the tag in text mode, then edit some text in the preview window and update it, wordpress wraps tags AROUND the very tag – exactly what I wanted to prevent with this plugin! Therefore, sorry: worthless…

  5. Jānis Elsts says:

    This plugin was designed to be used with the classical post editor, the one that was the default in older WordPress versions and can be re-enabled with the Classic Editor plugin in WP 5.5. Unfortunately, it generally won’t work with any visual, third-party editors like Elementor, WPBakery Page Builder, and so on.

  6. Kari Tiilikainen says:

    Hi!
    That was what I needed. Thank you! It works well in usual pages.

    I have also some pages greated as multisite. In multisitepages that plugin don’t work. If I insert [raw]­[/raw] in backend, in frontend there is ­ in text.

  7. Kari Tiilikainen says:

    Hi!
    That was what I needed. Thank you! It works well in usual pages.

    I have also some pages greated as multisite. In multisitepages that plugin don’t work. If I insert [raw]­mycode[/raw] in backend, in frontend there is mycode ­ in text.

  8. Jānis Elsts says:

    It looks like some of your sample code did not show properly in this comment section. If you like, you can send it to me via email instead. My email address is on the contact page.

  9. Kari Tiilikainen says:

    Hi!

    “My code” in [raw]­”mycode”[/raw] only disappears in backend after saving the page, but works in backend. In backend I can see it [raw][/raw] so it dont’t matter.

    It works also in multisite but in multisite where I use “RPS Include Content” -plugin which allows to insert content from one to another page. There your plugin don’t work with insertend content. In frontend appears [raw][/raw], not hypenation.

  10. Kari Tiilikainen says:

    “My code” in [raw]­”mycode”[/raw] only disappears in backend after saving the page, but works in FRONTEND. In backend I can see it [raw][/raw] so it dont’t matter.

    It works also in multisite but in multisite where I use “RPS Include Content” -plugin which allows to insert content from one to another page. There your plugin don’t work with insertend content. In frontend appears [raw][/raw], not hypenation.

  11. Kari Tiilikainen says:

    Correcting:

    Your plugin works fine in multisite with plugin “RPS Include Content”
    BUT it don’t work in multisite with plugin “Post Content Shortcodes”

  12. Jānis Elsts says:

    Do you use “[raw]” tags in code that you insert using the plugin “Post Content Shortcodes”? If so, that might explain why they don’t work. “[raw]…[/raw]” tags are not normal shortcodes, they’re just formatted similarly for convenience. These tags are usually processed before shortcodes (this is necessary to enable that some of the features that this plugin provides), so “[raw]” tags that were inserted or generated by a normal shortcode probably won’t work.

    Unfortunately, I don’t know any good workarounds for this problem.

Leave a Reply