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 disable the automatic formatting that WordPress applies to post content. This plugin adds a set of shortcodes that you can use to “protect” specific parts of your post and prevent WP from messing with them.

Download & Installation

Requirements :

  • WordPress 2.8 or later
  • If you use the free version, I strongly recommend disabling the visual editor. It (the editor) can mess up your code even if you use this plugin.

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 “Edit Post” screen:

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 ... or <!–raw–>…<!–/raw–> tags. The two versions work exactly the same, with one exception – the <!–raw–>’s won’t be visible to your visitors even if you deactivate the plugin.

Example :
<!--raw-->
This

is

a ‘test’!
<!–/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.

Related posts :

318 Responses to “Raw HTML Plugin for WordPress”

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

  2. 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 ๐Ÿ™‚

  3. Tony Cabrera says:

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

    Thanks

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

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

  7. White Shadow says:

    Thank you ๐Ÿ™‚

  8. Michael says:

    this is a critical plugin for my site, since all my posts use it, I’m terrified of upgrading to 2.5 and having things fall apart.

    From the last comments in this thread, it sounds like you think it should work, have you come across any issues since you made that comment a couple of weeks ago.

    I might take a crack at the 2.5 upgrade this weekend.

  9. White Shadow says:

    I’ve updated to 2.5.1 recently and the plugin seems to be working still.

  10. Tony Cabrera says:

    Michael,

    Same as you, all my post (112 of them) includes this plugin. I’ve converted to 2.5.1 and no problems at all. In fact it looks like 2.5 is a little more html-friendly. But I still require this plugin to work my blog.

    I did create a test blog (seprate site) and tested it first before I converted. You should probably create a test blog too just to be safe.

  11. HTML Guru says:

    So, if im trying to add in a youtube video will WP still reformat the objects?

  12. White Shadow says:

    I don’t know, I haven’t tried adding the videos directly (I used a plugin when I needed to insert a video). It would also depend on the WP version – 2.5 is said to be more forgiving in this regard.

  13. Voddie says:

    Ive just come across your plugin, I’m using WP 2.5.1, because I need to add a few tables within my pages.

    I did as instructed, unzipped, uploaded, activated and tried a simple table inclusion.

    I used the ….. syntax and it worked a dream.

    Brilliant plugin, thanks very much

    Voddie

  14. Hi all great information here and good thread to comment on.

    Can I ask though – how did you get this picked up and into google news?

    Very impressive that this blog is syndicated through Google and is it something that is just up to Google or you actively created?

    Obviously this is a popular blog with great data so well done on your seo success..

  15. White Shadow says:

    Ah, so it’s in Google News? Interesting…

    (or is the comment just very clever spam? in that case, congratulations, it works well ๐Ÿ˜‰ )

  16. Hikari says:

    Tnx a lot for this plugin dude, it’s the best plugin I use on my blog!

    btw, what’s the changes on 1.0.4?

  17. White Shadow says:

    @Hikari – Just a small bugfix in 1.0.4, no changes in functionality.

  18. Movie Goers says:

    thanks for the raw html =)

  19. ืฉื™ืฉ,ืฉื™ืฉืœืžื˜ื‘ื—,ืฉื™ืฉ ืœืžื˜ื‘ื—ื™ื

  20. teko says:

    Hi,

    I’m having some problems with this plugin. Posted a feedback here: http://wordpress.org/support/topic/187334?replies=1#post-798122

    Using 1.0.4, also tested in new wordpress 2.5.1 installation with no other plugins.

Leave a Reply