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.
Requirements & Download
I have only tested it in WordPress 2.3.1 - 2.6, 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:
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
January 17th, 2008 at 8:03 pm
[...] to “taming WP WYSIWYG” (thanks to Stephen Cronin for the heads up on this): “Raw HTML Plugin for WordPress” - “To prevent some part of your post or page from being processed and “texturized” [...]
January 17th, 2008 at 7:44 pm
*sorry, forgot to enable “Notify”*
bdt
January 17th, 2008 at 7:43 pm
Let the bells ring and the banners fly!
I’m sure you know you aren’t alone in being frustrated (read: head/desk happens way too often) by WYSIWYG’s behavior. I’ve been having an on-going exchange with Stephen Cronin in his blog and I’ve put together what I hope is a pretty comprehensive resource list at codex.wordpress. My point is: you’re responding to a very real need!
Would you do one thing for us? Would you, either here with an update or in another post, tell us what the plugin affects or changes to tame the editor?
TU!
–bentrem
January 16th, 2008 at 12:17 am
[...] Raw HTML is a WordPress plugin that allows you to put any code or script in your posts and display it to the visitor unmodified. [...]
January 13th, 2008 at 11:10 pm
…I’m afraid I don’t get it.
The bloginfo() template tag is a PHP function. Normally, it will not execute when placed inside your posts. You can use a different plugin, like ExecPHP, to make it execute.
However, if you place it inside the <!–start_raw–><end_raw–> tags, it will not work. This is intentional, and the whole point of the Raw HTML plugin - to prevent Wordpress (and other plugins, like ExecPHP) from parsing/changing parts of your posts.