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.

Download & Installation

raw-html.zip (3 KB)

Requirements :

  • WordPress 2.3.1 – 2.7
  • Disable visual editor for better results – some characters (e.g. the ampersand) may still be encoded if it’s enabled.

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 “Write” screen (requires WP 2.5+) :

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 <!–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 ;)

Share :
  • Reddit
  • del.icio.us
  • Digg
  • StumbleUpon
  • DZone
  • Ping.fm
  • Sphinn
  • Twitter
Related posts :

157 Responses to “Raw HTML Plugin for WordPress”

Pages: « 1 2 3 [4] 5 6 » Show All

  1. 68
    White Shadow says:

    @Aardvark – Yes, it hasn’t been extensively tested with the visual editor.

  2. 70
    nirsound says:

    Is it possible to apply the plugin to all posts and pages? (without using the [raw][/raw] every time)

  3. 71
    White Shadow says:

    @nirsound – not in this implementation, but it’s an interesting idea.

  4. This is a great plugin

  5. 73
    rap dinle says:

    I’ve been looking all over the Internet for a way to do this. Thanks for sharing and making my day even better!

  6. 74
    nirsound says:

    Thanks! I am looking forward to general setting “Apply Raw HTML to all posts and pages” in the next release…. ;) Meanwhile, can you think of a simple change to the plugin code to force wordpress to default to Raw HTML mode? (without writing the {!–start_raw–}{!–end_raw–} every time)

  7. 75
    White Shadow says:

    When I finally get around to updating my old plugins, perhaps ;)

  8. [...] HTML Update The Raw HTML plugin has been updated! In case you didn’t know, Raw HTML is my WordPress plugin that lets you use [...]

  9. [...] Another case if we want to put any special characters (apostrophie, quote) and any script. To enable javascript and put RAW HTML inside wp post, we must install RAW HTML [...]

  10. [...] Are you trying to add a flash object inside a wordpress post using the <object> tag? Your post will  probably look screwed up. So if you don’t care about xhtml and all that stuff try the easy fix: get the raw html plugin [...]

  11. 80
    Artsy Crafter says:

    I really love this plug in (the raw html one). I am new at wordpress blogging and it was so easy!

    Thanks!!

  12. 81
    Hikari says:

    tnx a lot, this is the most critical plugin I use

  13. 82
    Dusty says:

    Unfortunately, when I tried this, I still had the problem I was having before – with the auto-formatting, if I put line breaks in my table coding to make it manageable, there will be a huge block of space above each table, the sum of all the line breaks in the coding. on LJ, I know that turning the auto-formatting off will fix that and I was hoping that this would do the same. Unfortunately, I still got the large chunks of space, both when I checked the box and when I ran the !-start_raw codes.

  14. 83
    White Shadow says:

    Hmm, how about an example of the problematic HTML?

  15. 84
    Ironboots says:

    Was wondering, (new to WP) how one goes about disabling the Visual Editor?
    Thanks.

  16. 85
    White Shadow says:

    You can turn off the visual editor in Users -> Your profile. Tick the “Disable visual editor when writing” checkbox on that page.

  17. 86
    Ironboots says:

    OMG, I don’t know how I missed that [embarrassed]. Thank you.

  18. 87
    Ironboots says:

    Great plug-in too btw, thanks for sharing.

  19. 88
    Eric says:

    Thank, you! This is a fantablous plugin!!!

  20. 89
    Bob says:

    I’ve used this in the past and it’s worked brilliantly – however with a fresh install of WP 2.7 -> 2.71 it seems to be ignored… anyone else having this problem?

  21. 90
    White Shadow says:

    I’ve upgraded to WP 2.7.1 on this site and it seems to be working fine.

  22. [...] で、WordPressの自動整形を止めるプラグインを探してみた。 まず試してみたのがRaw HTML capabilityプラグイン。 [...]

  23. 92
    Bob says:

    As a follow up to my comment yesterday, I found that a plugin – “Secure and Accessible PHP Contact Form” – conflicted with one of the other plugins I had installed, and after removing it your plugin also seems to have returned to its former glory – two birds with one stone!

  24. 93
    Ben Tremblay says:

    Do you mean http://green-beast.com/blog/?page_id=136 Contact Form?
    Also: which plugin was causing problems?
    (Information is power, yes?)

  25. 94
    Latitude 57 says:

    Thanks for the plugin, exactly what i was looking for.

  26. 95
    Enjay says:

    Perfect! Thanks a million!

  27. 96
    Jacked says:

    RAW HTML is incompatible with CFORMS II

    Basicially, Raw HTML automatically adds a tag at the end of most of the fields created by Cforms

  28. 97
    jacked says:

    oh, and I am using WP 2.6

Pages: « 1 2 3 [4] 5 6 » Show All

Leave a Reply