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. 164
    Chris says:

    A temporary solution would be a “remember selection in a cookie” checkbox. How about that? ;)

  2. 165
    White Shadow says:

    Argh, fine. I’ve added a “Raw HTML defaults” panel to the “Screen Options” box (and it only took me two days to figure out how to do that :P ). You should get an update notification soon.

  3. 166
    Chris says:

    Awesome!!! Thanks, m8! :)

  4. 167
    BG! says:

    “I’ve added a “Raw HTML defaults” panel to the “Screen Options” box…”

    I’ve just updated and looked for this panel and can’t find it anywhere :-(

    Any ideas?

  5. 168
    White Shadow says:

    What’s your WP version? It will only show up in 3.0.

  6. 169
    Chris says:

    BG: it shows up when you click “screen options” in the top right corner during new post composition.

    This works fantastic, you just saved like an hour of everybody’s lives :)

    The default settings should also work when I uncheck the RAW HTML box in the screen options, correct?

  7. 170
    White Shadow says:

    Mmm, no. But you can collapse the box and put it at the bottom of the page, and the defaults will be applied when you save/update a post.

  8. 171
    Chris says:

    Ok, thanks :)

  9. 172
    BG! says:

    Got it now, many thanks!

  10. [...] Raw HTML capability by Janis Elsts [...]

  11. 174
    Chris says:

    Just wanted to let you know that the defaults do work even if the raw html box is hidden in the screen options. Testen on a handful of posts :)
    This is great! :)
    You may want to consider adding a explanation on where to find the defaults. The FAQ of WP Plugins repository would be a good place to publish it on :)

  12. 176
    jamey says:

    Doesn’t work for me – WP 3.0.

  13. 178
    Jason says:

    I’m having a weird issue where this plugin works perfectly for some users, but strips ids for others.

    I’m using WordPress 3.0 with multisite turned on. Users who are Super Admins on the site have no trouble; everyone else is having trouble.

  14. 179
    White Shadow says:

    What do you mean by “strips ids”?

  15. 180
    Jason says:

    I have a chunk of code:
    [RAW]
    stuff

    When certain users try to use that, it strips out the id=”somename” and just leave the div there. Nothing else is changed.

  16. 181
    Jason says:

    The comments keep eating my div tags!

  17. 182
    Howard E. Deutch says:

    I want to change some of the html on my WordPress home page. Can I do this with raw-html?

    Suppose I create an entirely new page using HyperEdit or another html editor. Can I copy the source code from there and create a WordPress page by using raw_html?

  18. 183
    White Shadow says:

    Assuming you only want to change the content part of the homepage – yes. However, if you need to change things in the sidebar, header and so on, something like a custom page template would probably work better.

  19. [...] Raw HTML Plugin for WordPress | W-Shadow.com – Permet l’insertion du code dans wordpress sans interprétation, évitant des problèmes pour le code html, javascript etc. Filed under Bookmark Tagged annuaire, intallperso, logiciel, outils, piwik, plugins, pratique, server, web, WordPress Comment (RSS)  |  Trackback  |  Permalink [...]

  20. [...] Check Raw HTML Plugin for WordPress [...]

  21. [...] Raw HTML: “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.” [...]

  22. [...] Raw HTML Capability by Janis Elsts RawHTML lets you use any HTML or JavaScript code without WP messing it up. It also [...]

  23. 188
    bob says:

    Thanks for your work on this plugin – I have it installed on WP3.0.1 and it seems to be working for me apart from WP (the insatiable beast) wrapping the commented tags:

    and

    which upsets the intended layout a little.

    Any comments on this would be greatly appreciated.
    Cheers

  24. 189
    bob says:

    ah ok, no luck posting code on comments :) – anyway the !–start_raw– tags get wrapped in paragraphs

  25. 190
    White Shadow says:

    Try putting the tags inline with other content, like this :

    other content<!--start_raw-->"raw" html here<!--end_raw-->other content
  26. 191
    rap says:

    Thank you!
    it’s a very useful plugin

  27. 192
    Riccardo Ferrari says:

    I have a studio press them and your plg in doesn’t work

  28. 193
    Guleti says:

    I was tensed searching for this, thanks my friend. Now html are looking good !!!

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

Leave a Reply