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 in my posts and display it to the visitor unmodified.
Requirements & Download
I have only tested it in WordPress 2.3.1, but I’m fairly certain the plugin will work in older WP 2.x versions, too. I recommend disabling the visual editor for better results - if it’s enabled enabled, some characters (e.g. the ampersand) may still be encoded.
The installation is straightforward - download the zip file, unzip, upload the raw-html folder to /wp-content/plugins and activate it in the Plugins tab.
Download raw-html.zip (2 KB)
Using the plugin
To prevent some 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
You might also be interested in another functionally similar plugin - WP Unformatted - that works on per-post basis.
Related posts:






May 7th, 2008 at 7:36 pm
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.
May 6th, 2008 at 2:25 pm
So, if im trying to add in a youtube video will WP still reformat the objects?
May 2nd, 2008 at 9:22 pm
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.
May 1st, 2008 at 10:31 pm
I’ve updated to 2.5.1 recently and the plugin seems to be working still.
May 1st, 2008 at 10:08 pm
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.
April 22nd, 2008 at 5:31 pm
Thank you
April 22nd, 2008 at 5:28 pm
Test site looks good, I’ll convert to 2.5 sometime this weekend. Donation on its way, thanks again for the plugin!
April 22nd, 2008 at 3:33 am
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.
April 22nd, 2008 at 12:16 am
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.
April 22nd, 2008 at 12:07 am
Love this plugin. Would love to see 2.5 compatibility. Would also be interested in donation when it’s done.
Thanks
April 20th, 2008 at 12:44 pm
Looks like the WP 2.5 editor is a bit more flexible in this regard, though obviously not perfect. Anyway, good luck
April 20th, 2008 at 3:04 am
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.
April 6th, 2008 at 7:27 pm
Yes, I plan to eventually update all my plugins for WP 2.5. I’m working on the Single Click Updater plugin at the moment.
April 6th, 2008 at 7:12 pm
It seems Wordpress 2.5 doesn’t like the plugin. Will you be updating it?
I hope so
Thanks
April 2nd, 2008 at 2:05 am
[...] Raw HTML. This WordPress plugin could come in handy. [...]
March 31st, 2008 at 7:09 am
[...] Raw HTML - Best plug-in ever. Allows you to wrap PHP/HTML/PHP codeblocks in special comments which prevent WordPress from reformatting or encoding them (shocking this is necessary, but a very welcome plug-in) [...]
March 22nd, 2008 at 11:41 pm
[...] Plugin Homepage ; [...]
March 19th, 2008 at 2:26 pm
thnak you
February 21st, 2008 at 12:13 pm
[...] Raw HTML capability 1.0.2 » Janis Elsts (url) Lets you enter raw HTML in your posts. See website for details. [...]
February 7th, 2008 at 11:12 pm
[...] Raw-HTML leaves the HTML you hand-code in an individual post alone. In other words, the WP engine doesn’t b0rk your HTML. [...]
January 30th, 2008 at 11:08 am
[...] Visit [...]
January 30th, 2008 at 10:01 am
[...] Visit [...]
January 27th, 2008 at 4:08 am
Thank you really. I have used it in my site and it works well. Keep on!
January 25th, 2008 at 12:38 am
Very good!
Thanks for this
January 23rd, 2008 at 6:38 am
[...] Plugin Homepage [...]
January 20th, 2008 at 5:58 pm
Not integrate, but it looks like an interesting idea for a new plugin. I’ll think about it.
January 20th, 2008 at 4:50 am
Any way you can integrate htmLawed into this plug-in? Among other things, htmLawed can be used to restrict HTML tags as well as to balance them.
January 17th, 2008 at 9:03 pm
You’re welcome
January 17th, 2008 at 8:45 pm
Wow! “plugin … saves it in internal variables before WordPress can “prettify”. Then … adds back the “raw” content in the right places.” *whooot!* That’s amazing!
Please don’t take this as diss: goes to show what lengths we’ll go to in order to escape WYSIWYG’s clutches! ;-P
thanks for this
cheers
January 17th, 2008 at 8:12 pm
The plugin doesn’t “tame” the editor in any way (that’s why I say that using the visual editor is “not recommended” in my post).
Actually, it only runs when a post is displayed. The plugin intercepts the content surrounded by the special tags and saves it in internal variables before WordPress can “prettify” it. Then, after WP is done messing with the rest of the post, it adds back the “raw” content in the right places.
So the visual editor is still at large