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+) :

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
Done. The update will be up on wordpress.org in a few minutes.
RAW-HTML I had view a lot of plug-ins to find this one. Hell yea…this was exactly what I was looking for. The reason I needed this plug-in was all the Google Docs plug-ins that I had used…failed! This plug-in is in fact the most successful plug-in to use for embedding Google Docs.
It worked!!
I embedded a google form on my wp site!!
Yay!
Thank you!
Wow that great. Thanks for that pal..
It works great on Posts how can I get this to work on Pages?
Normally you don’t need to do anything special to make it work on pages. Can you think of anything unusual about your pages that might be causing the problem? Non-default templates? Some kind of page plugin (whatever that might be)?
For whatever reason it Pages mess up my HTML as bad as Post… Huge spaces all kinds of line breaks….
For now I will forward my pages to a post and use this great tool.
Unless someone has experienced this crazy problem.
Thanks WS
I’m sorry, but I can’t see where everyone is having these problems, even in the latest edition of WP. For most of these issues regarding html, a simple html editor can be used first to test the html. When applying the plug-in, I had never experienced any difficulties where the plug-in didn’t work. Is there anything that anyone would like me to try in attempt to localize any further issues?
hello!
how about, instead of having 4 custom fields for each post, having only 1 and storing the 4 values in a string?
It would avoid cluttering the database, since each of them is a simple boolean value.
For backward compatibility, everytime a post is read you verify both cases, but for writing you always try to remove old custom fields and update it with new one.
Wordpress should natively have options to remove these filters from posts, tnx for the plugin
The example worked fine. Then I tried on frame redirect code and no redirect. Does WP filter anyway?
Could you post the code you’re trying to use? I’m not quite clear on what “frame redirect code” means.
[...] automatic formatting functions from wordpress. No more useless P-tags in the middle of your post andVisit plugin site »9 – Shadowbox JSA javascript media viewer similar to Lightbox and Thickbox. Supports all types [...]
[...] Raw HTML capability 修正wordpress的自動修正語法不當的狀況(例如美式的引號會被轉成其他符號)。 [...]
Great plugin. One question though. How would I get the code to process other shortcodes inside the [RAW] tags? I use a lot of short codes, and the plugin just echoes the short code tags instead of processing them.
In short, you can’t. The whole point of this plugin is not to let WP modify anything within the [RAW] tags. So not executing shortcodes is by design.
[...] nazywa się Raw HTML http://w-shadow.com/blog/2007/12/13/raw-html-in-wordpress/ i doskonale się to tego nadał. Po prostu we wpisie umieszczamy tagi <!–start_raw–> i [...]
After I posted that, I realized what a stupid question it was. I don’t need to wrap my code in RAW tags. I just disable autop with the checkboxes and all my shortcodes work great.
@Ryan – Good on yuh for saying so. In my experience it’s just that sort of “mistake” that gets me chasing my tail … horribly frustrating to over-look the obvious.
cheers!
Hi,
I would just like to say “Thank-you” for making such a time saving plugin! I spent all of today trying to add an html page to WordPress. It wasn’t as easy as just copying from the to . Your plugin was the light at the end of a dark tunnel! This dark tunnel lasted the whole day!
Thank-you, Thank-you!!!
It seems this does not prevent all WOrdpress filtering. I am trying to use some nonstandard HTML tags within post and even with this plugin, Worpdrepss stil manages to completely remove those tags.
It does not happen if I enter tags in HTML mode and save post. It happens when I enter tags in HTML mode and then just switch to WSYIWG mode. Tags are deleted at once.
I need those tags as they are used for additional formatting on post display which I do from my plugin.
Is there way to prevent this kind of filtering HTML?
This plugin does not affect the visual editor in any way. It’s purpose is to deal with the filters that WordPress applies when displaying the post on your blog.
Solution : Don’t use the visual editor when you need to use non-standard tags.
I also noticed that plugin does not work on posts displayed on first page in blog, and RSS feeds.
Hmm, I’ll put fixing that on my to-do list.
[...] Raw HTML Plugin for WordPress Raw HTML Plugin for WordPress doesn’t let WordPress to put backslashes in front of apostrophes, insert superfluous tags in place of newlines, and break HTML in various ways. This plugin lets you put any code or script (e.g. JavaScript) in your posts and display it to the visitor unmodified. [...]
Simply, i love you
I would LOVE to see the default settings on for this plugin… Any chance to have it?
I’ll add it to my to-do list, but it’s unlikely to get implemented any time soon.
Thanks! Although if someone installs this plugin, it’s likely he’s using it so changing the default box to checked would save time for most of us. It’s just 4 extra attributes in HTML, please consider an earlier upgrade
Right.
* 4 extra HTML attributes.
* An extra (per-user?) option in the database for storing the default settings.
* New UI elements for setting the defaults.
* Additional code for loading/saving the defaults.
* Additional code for removing the defaults on uninstall.
* Additional code for handling edge cases (what about posts created before the new feature was added?).
Yeah, I know. I just ment you to hardcode the attributes into the plugin, since I know it’s a lot of work to implement it in the panel. Although you make a point about the edge cases. Too bad