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 put any code or script (e.g. JavaScript) in my posts and display it to the visitor unmodified.

Requirements & Download

I have only tested it in WordPress 2.3.1 - 2.6, but I’m fairly certain the plugin will work in older WP 2.x versions, too. I recommend disabling the visual editor for better results - if it’s enabled enabled, some characters (e.g. the ampersand) may still be encoded.

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

Download raw-html.zip (2 KB)

Using the plugin

To prevent some part of your post or page from being processed and “texturized” by WordPress, wrap it in <!–start_raw–>…<!–end_raw–> or [RAW]…[/RAW] tags. The two versions work exactly the same, but the latter may be handy if you’re using the visual editor (not recommended).

Example :
<!--start_raw-->
This

is

a 'test'!
<!--end_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. If it works for you, consider yourself lucky ;)

You might also be interested in another functionally similar plugin - WP Unformatted - that works on per-post basis.

Related posts :

68 Responses to “Raw HTML Plugin for WordPress”

Pages: « 3 2 [1] Show All

  1. 8
    Buffer Dump 17JAN08 « Feet up, eyes closed, head back Says:

    [...] to “taming WP WYSIWYG” (thanks to Stephen Cronin for the heads up on this): “Raw HTML Plugin for WordPress” - “To prevent some part of your post or page from being processed and “texturized” [...]

  2. 7
    Ben Tremblay Says:

    *sorry, forgot to enable “Notify”*
    bdt

  3. 6
    Ben Tremblay Says:

    Let the bells ring and the banners fly!

    I’m sure you know you aren’t alone in being frustrated (read: head/desk happens way too often) by WYSIWYG’s behavior. I’ve been having an on-going exchange with Stephen Cronin in his blog and I’ve put together what I hope is a pretty comprehensive resource list at codex.wordpress. My point is: you’re responding to a very real need!

    Would you do one thing for us? Would you, either here with an update or in another post, tell us what the plugin affects or changes to tame the editor?

    TU!
    –bentrem

  4. 5
    WordPress Plugin — Raw HTML | AVINASH 2.0 Says:

    [...] Raw HTML is a WordPress plugin that allows you to put any code or script in your posts and display it to the visitor unmodified. [...]

  5. 4
    White Shadow Says:

    …I’m afraid I don’t get it.

    The bloginfo() template tag is a PHP function. Normally, it will not execute when placed inside your posts. You can use a different plugin, like ExecPHP, to make it execute.

    However, if you place it inside the <!–start_raw–><end_raw–> tags, it will not work. This is intentional, and the whole point of the Raw HTML plugin - to prevent Wordpress (and other plugins, like ExecPHP) from parsing/changing parts of your posts.

  6. 3
    Michael Says:

    Hope you can help.

    I’ve installed the raw html plugin and turned off the visual editor in my profile to be able to have more control over the formatting of my posts. Embedded images show up fine on the home page, but have path problems in the archives and comment pages because of the dynamic directory structure

    I have been hard coding my image paths inside posts

    I can see that’s problematic and have found I should be using something like /images/vd_competitive.gif”

    Since I’m operating inside the raw plugin tags… do I need to escape the bloginfo tag.

    This should be simple. Do the template tags only work in the visual editor context. Help, this simple issue is really frustrating and I’ve found several threads on much the same topic but none anticipate the raw html issue.

  7. 2
    De redactie .be Says:

    [...] een plugin gevonden voor wordpress waarmee de embedded items van de VRT wél te integreren zijn in wordpress. [...]

  8. 1
    blacksnoopy Says:

    Thank you!
    :)

Pages: « 3 2 [1] Show All

Leave a Reply