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:

63 Responses to “Raw HTML Plugin for WordPress”

Pages: « 3 [2] 1 » Show All

  1. 33
    White Shadow Says:

    Thank you :)

  2. 32
    Tony Cabrera Says:

    Test site looks good, I’ll convert to 2.5 sometime this weekend. Donation on its way, thanks again for the plugin!

  3. 31
    Tony Cabrera Says:

    Not yet, I’ll try it on a separate blog first. I’ve put too much work on my current one to screw it up.

    Yes, I’d be happy to donate. Your plugin is exactly what I needed.

  4. 30
    White Shadow Says:

    You’re welcome :)
    By the way, have you tried using the current version in WP 2.5? I haven’t done in-depth testing, but it seems to work OK on my blogs that are running WordPress 2.5.

    Guess I’ll have to finally put up a “Donate” button on the site.

  5. 29
    Tony Cabrera Says:

    Love this plugin. Would love to see 2.5 compatibility. Would also be interested in donation when it’s done.

    Thanks

  6. 28
    White Shadow Says:

    Looks like the WP 2.5 editor is a bit more flexible in this regard, though obviously not perfect. Anyway, good luck :)

  7. 27
    Alec Says:

    Thanks for the plugin.

    We took a different approach to the vagaries of the Wordpress visual editor - which does terrible things to code of all times. Instead of fighting a losing war with the built-in WYSIWYG editor, we wrote a hardcore adaptation of FCK including an integrated image uploader-manager specifically for Wordpress.

    We still do have some issues with trying to place straight code (particularly html code) within a post. After flipping back and forth between WYSIWYG and source, the angled brackets turn to html entities, like it or not. We’ll try to adapt your code to Foliopress WYSIWYG.

  8. 26
    White Shadow Says:

    Yes, I plan to eventually update all my plugins for WP 2.5. I’m working on the Single Click Updater plugin at the moment.

  9. 25
    Egon Says:

    It seems Wordpress 2.5 doesn’t like the plugin. Will you be updating it?
    I hope so :-)

    Thanks

  10. 24
    Raw HTML | Futurosity Grapevine Says:

    [...] Raw HTML. This WordPress plugin could come in handy. [...]

  11. 23
    Mike Davidson - Mike Industries Now Powered By WordPress Says:

    [...] Raw HTML - Best plug-in ever. Allows you to wrap PHP/HTML/PHP codeblocks in special comments which prevent WordPress from reformatting or encoding them (shocking this is necessary, but a very welcome plug-in) [...]

  12. 22
    Wp Wordpress » Blog Archive » Raw HTML Says:

    [...] Plugin Homepage ; [...]

  13. 21
    absolut-desing Says:

    thnak you :D

  14. 20
    The Plugin | Daniel Daphone Says:

    [...]   Raw HTML capability 1.0.2 » Janis Elsts (url) Lets you enter raw HTML in your posts. See website for details. [...]

  15. 19
    Big IDEA » Blog Archive » Three helpful Wordpress plugins for web geeks Says:

    [...] Raw-HTML leaves the HTML you hand-code in an individual post alone. In other words, the WP engine doesn’t b0rk your HTML. [...]

  16. 18
    Wp Wordpress » Blog Archive » Raw HTML capability Says:

    [...] Visit [...]

  17. 17
    WordPress Plugins Database » Blog Archive » Raw HTML capability Says:

    [...] Visit [...]

  18. 16
    Lee Says:

    Thank you really. I have used it in my site and it works well. Keep on!

  19. 15
    Fernando Says:

    Very good!

    Thanks for this

  20. 14
    Raw HTML_Wordpress plugin Says:

    [...] Plugin Homepage [...]

  21. 13
    White Shadow Says:

    Not integrate, but it looks like an interesting idea for a new plugin. I’ll think about it.

  22. 12
    Deena Seth Says:

    Any way you can integrate htmLawed into this plug-in? Among other things, htmLawed can be used to restrict HTML tags as well as to balance them.

  23. 11
    White Shadow Says:

    You’re welcome :)

  24. 10
    Ben Tremblay Says:

    Wow! “plugin … saves it in internal variables before WordPress can “prettify”. Then … adds back the “raw” content in the right places.” *whooot!* That’s amazing!

    Please don’t take this as diss: goes to show what lengths we’ll go to in order to escape WYSIWYG’s clutches! ;-P

    thanks for this
    cheers

  25. 9
    White Shadow Says:

    The plugin doesn’t “tame” the editor in any way (that’s why I say that using the visual editor is “not recommended” in my post).

    Actually, it only runs when a post is displayed. The plugin intercepts the content surrounded by the special tags and saves it in internal variables before WordPress can “prettify” it. Then, after WP is done messing with the rest of the post, it adds back the “raw” content in the right places.

    So the visual editor is still at large ;)

  26. 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” [...]

  27. 7
    Ben Tremblay Says:

    *sorry, forgot to enable “Notify”*
    bdt

  28. 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

  29. 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. [...]

  30. 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.

Pages: « 3 [2] 1 » Show All

Leave a Reply