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.6 – 3.0
  • 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 :

193 Responses to “Raw HTML Plugin for WordPress”

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

  1. 134
    White Shadow says:

    Done. The update will be up on wordpress.org in a few minutes.

  2. 135
    Mario Stevenson says:

    RAW-HTML I had view a lot of plug-ins to find this one. Hell yea…this was exactly what I was looking for. The reason I needed this plug-in was all the Google Docs plug-ins that I had used…failed! This plug-in is in fact the most successful plug-in to use for embedding Google Docs.

  3. 136
    Dan says:

    It worked!!
    I embedded a google form on my wp site!!
    Yay!
    Thank you!

  4. 137
    Shaliwahan says:

    Wow that great. Thanks for that pal..

  5. 138
    Alberto says:

    It works great on Posts how can I get this to work on Pages?

  6. 139
    White Shadow says:

    Normally you don’t need to do anything special to make it work on pages. Can you think of anything unusual about your pages that might be causing the problem? Non-default templates? Some kind of page plugin (whatever that might be)?

  7. 140
    Alberto says:

    For whatever reason it Pages mess up my HTML as bad as Post… Huge spaces all kinds of line breaks….

    For now I will forward my pages to a post and use this great tool.

    Unless someone has experienced this crazy problem.

    Thanks WS

  8. 141
    Mario Stevenson says:

    I’m sorry, but I can’t see where everyone is having these problems, even in the latest edition of WP. For most of these issues regarding html, a simple html editor can be used first to test the html. When applying the plug-in, I had never experienced any difficulties where the plug-in didn’t work. Is there anything that anyone would like me to try in attempt to localize any further issues?

  9. 142
    Hikari says:

    hello!

    how about, instead of having 4 custom fields for each post, having only 1 and storing the 4 values in a string?

    It would avoid cluttering the database, since each of them is a simple boolean value.

    For backward compatibility, everytime a post is read you verify both cases, but for writing you always try to remove old custom fields and update it with new one.

    Wordpress should natively have options to remove these filters from posts, tnx for the plugin :D

  10. 143
    don says:

    The example worked fine. Then I tried on frame redirect code and no redirect. Does WP filter anyway?

  11. 144
    White Shadow says:

    Could you post the code you’re trying to use? I’m not quite clear on what “frame redirect code” means.

  12. [...] automatic formatting functions from wordpress. No more useless P-tags in the middle of your post andVisit plugin site »9 – Shadowbox JSA javascript media viewer similar to Lightbox and Thickbox. Supports all types [...]

  13. [...] Raw HTML capability 修正wordpress的自動修正語法不當的狀況(例如美式的引號會被轉成其他符號)。 [...]

  14. 147
    Ryan says:

    Great plugin. One question though. How would I get the code to process other shortcodes inside the [RAW] tags? I use a lot of short codes, and the plugin just echoes the short code tags instead of processing them.

  15. 148
    White Shadow says:

    In short, you can’t. The whole point of this plugin is not to let WP modify anything within the [RAW] tags. So not executing shortcodes is by design.

  16. [...] nazywa się Raw HTML http://w-shadow.com/blog/2007/12/13/raw-html-in-wordpress/ i doskonale się to tego nadał. Po prostu we wpisie umieszczamy tagi <!–start_raw–> i [...]

  17. 150
    Ryan says:

    After I posted that, I realized what a stupid question it was. I don’t need to wrap my code in RAW tags. I just disable autop with the checkboxes and all my shortcodes work great.

  18. 151
    Ben Tremblay says:

    @Ryan – Good on yuh for saying so. In my experience it’s just that sort of “mistake” that gets me chasing my tail … horribly frustrating to over-look the obvious.

    cheers!

  19. 152
    MD says:

    Hi,

    I would just like to say “Thank-you” for making such a time saving plugin! I spent all of today trying to add an html page to WordPress. It wasn’t as easy as just copying from the to . Your plugin was the light at the end of a dark tunnel! This dark tunnel lasted the whole day!

    Thank-you, Thank-you!!!

  20. 153
    Predrag Supurovic says:

    It seems this does not prevent all WOrdpress filtering. I am trying to use some nonstandard HTML tags within post and even with this plugin, Worpdrepss stil manages to completely remove those tags.

    It does not happen if I enter tags in HTML mode and save post. It happens when I enter tags in HTML mode and then just switch to WSYIWG mode. Tags are deleted at once.

    I need those tags as they are used for additional formatting on post display which I do from my plugin.

    Is there way to prevent this kind of filtering HTML?

  21. 154
    White Shadow says:

    This plugin does not affect the visual editor in any way. It’s purpose is to deal with the filters that WordPress applies when displaying the post on your blog.

    Solution : Don’t use the visual editor when you need to use non-standard tags.

  22. 155
    Predrag Supurović says:

    I also noticed that plugin does not work on posts displayed on first page in blog, and RSS feeds.

  23. 156
    White Shadow says:

    Hmm, I’ll put fixing that on my to-do list.

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

  25. 158
    txeo says:

    Simply, i love you

  26. 159
    Chris says:

    I would LOVE to see the default settings on for this plugin… Any chance to have it?

  27. 160
    White Shadow says:

    I’ll add it to my to-do list, but it’s unlikely to get implemented any time soon.

  28. 161
    Chris says:

    Thanks! Although if someone installs this plugin, it’s likely he’s using it so changing the default box to checked would save time for most of us. It’s just 4 extra attributes in HTML, please consider an earlier upgrade ;)

  29. 162
    White Shadow says:

    Right.

    * 4 extra HTML attributes.
    * An extra (per-user?) option in the database for storing the default settings.
    * New UI elements for setting the defaults.
    * Additional code for loading/saving the defaults.
    * Additional code for removing the defaults on uninstall.
    * Additional code for handling edge cases (what about posts created before the new feature was added?).

    :P

  30. 163
    Chris says:

    Yeah, I know. I just ment you to hardcode the attributes into the plugin, since I know it’s a lot of work to implement it in the panel. Although you make a point about the edge cases. Too bad :(

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

Leave a Reply