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
Related posts :

143 Responses to “Raw HTML Plugin for WordPress”

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

  1. 84
    Ironboots says:

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

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

  3. 86
    Ironboots says:

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

  4. 87
    Ironboots says:

    Great plug-in too btw, thanks for sharing.

  5. 88
    Eric says:

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

  6. 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?

  7. 90
    White Shadow says:

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

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

  9. 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!

  10. 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?)

  11. 94
    Latitude 57 says:

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

  12. 95
    Enjay says:

    Perfect! Thanks a million!

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

  14. 97
    jacked says:

    oh, and I am using WP 2.6

  15. 98
    White Shadow says:

    This will be fixed in version 1.2. You should get the update notification in your WP Dashboard within 24 hours.

  16. 99
    Mike says:

    Hello, thanks for your work on this plugin. I’m having some issues. I’ve got WP 2.6.3 and I don’t get an options box added to my write or manage pages. I’ve used the card code method and that seems to work to a point. WP is still stripping out line breaks and also non breaking spaces in my html. This happens when I paste as html then switch to visual editor, then back to html. I can’t turn off visual editor because eventually I have to hand this over to a client who will want a wysiwyg. I never really got why wordpress is rewriting code anyway.

  17. 100
    Mike says:

    It strips the paragraph tags out of the raw code as well.

  18. 101
    White Shadow says:

    As noted in the post, the plugin isn’t really reliable when used with the visual editor. Unfortunately I’m not sufficiently familiar with the inner workings of the editor to fix this (at least at the moment). Sorry.

  19. [...] Raw HTML Plugin for WordPress Raw HTML Plugin for WordPress doesn’t let WordPress to put backslashes in front of apostrophes, insert superfluous tags in place of newlines, and break HTML in various ways. This plugin lets you put any code or script (e.g. JavaScript) in your posts and display it to the visitor unmodified. [...]

  20. 103
    Lauri says:

    Mike, I had the same issue with missing options before I upgraded to 2.7.1. Now it works great! Thanks for this plug-in. I was so frustrated with WP putting paragraph tags around my images and breaking my layout.

  21. 105
    Tracy says:

    I am trying to add an affiliate to my site. However, each time I add the code and publish. The code remains there it does not convert to a button. Is this something I need. I am not sure what I need. This is very confusing to me. Can someone please help me.

  22. 106
    Eric P says:

    Tracy, Can you be more specific. Perhaps show the code and the page where this is happening. And firstly, have you determined if the code is working o.k. outside of wordpress…like on a stand alone HTML page?

  23. [...] Raw HTML capability [...]

  24. 108
    Shane says:

    Hi, there!

    Multiple code blocks of [RAW] … [/RAW] do NOT work well in one passage, would you please fix that?

    Thank you!

    And by the way it’s a very useful plugin!

  25. 109
    rap dinle says:

    Thank you!
    it’s a very useful plugin

  26. 110
    White Shadow says:

    @ Shane : Fixed in 1.2.2.

  27. 111
    Gianfranco says:

    One question. Does it remove the “auto p” from images as well?

  28. 112
    White Shadow says:

    I haven’t tested it, but I think it would.

  29. 113
    Shane says:

    @White Shadow
    Thanks for your work!

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

Leave a Reply