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 :
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.
January 13th, 2008 at 10:49 pm
Hope you can help.
I’ve installed the raw html plugin and turned off the visual editor in my profile to be able to have more control over the formatting of my posts. Embedded images show up fine on the home page, but have path problems in the archives and comment pages because of the dynamic directory structure
I have been hard coding my image paths inside posts
I can see that’s problematic and have found I should be using something like /images/vd_competitive.gif”
Since I’m operating inside the raw plugin tags… do I need to escape the bloginfo tag.
This should be simple. Do the template tags only work in the visual editor context. Help, this simple issue is really frustrating and I’ve found several threads on much the same topic but none anticipate the raw html issue.
January 7th, 2008 at 6:32 pm
[...] een plugin gevonden voor wordpress waarmee de embedded items van de VRT wél te integreren zijn in wordpress. [...]
January 6th, 2008 at 2:27 am
Thank you!