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 :

288 Responses to “Raw HTML Plugin for WordPress”

  1. [...] balise <code> (mais dans ce cas, j’utilise le short­code [raw], per­mit par l’extension Raw HTML) ou bien dans un texte dans une autre langue (lang="en"» ou xml:lang="en" , par [...]

  2. [...] plus ana­ly­ser qu’un texte se trouve dans une balise <code> (j’aurais bien uti­lisé Raw HTML et sa balise <!–raw–>, mais il y a une incom­pa­ti­bi­lité) ou bien dans un texte [...]

  3. [...] Having realized that WordPress does not allow us to type JavaScript in our posts, I tried to find out how to add Web Ring navigation URL into a post. After some googling and trial and error, finally got this nice plugin called RAW HTML. [...]

  4. [...] Having realized that WordPress does not allow us to type JavaScript in our posts (or pages), I tried to find out how to add Web Ring navigation URL into a post. After some googling and trial and error, finally got this nice plugin called RAW HTML. [...]

  5. [...] Versão 1.4.8 | Por Janis Elsts | Visitar o site do plugin [...]

  6. thomas says:

    hi there,

    when activating raw html, all other plugins that parse the post-text in some kind of way aren’t executed any more.

    when deactivating add_filter(‘the_content’, ‘wsh_extract_exclusions’, 2); all works fine – more or less ;)
    breaks are keeped, only thing is, that edit text was:
    -raw-
    bla
    bla

    bla
    -/raw-

    is in html now:
    -raw–/raw-
    bla
    bla

    bla

    the rest is as it should be.

    have a hint why?

    regards,
    thomas

  7. Jānis Elsts says:

    When you say other plugins aren’t executed any more, do you mean that they no longer work on the text in [raw]…[/raw] tags, or that they stop working completely, even in posts that don’t use the [raw]” tags?

    If it’s the former, then that’s the intended result – Raw HTML protects text within [raw] tags from being modified by WordPress and most other plugins. This is why shortcodes and other dynamically generated code won’t work inside [raw] tags.

    On the other hand, if other plugins stop working completely, that sounds like a plugin conflict. Could you tell me what plugins you’re using so that I can install them and test them for compatibility issues?

Leave a Reply