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. kghost says:

    What a great plugin !! Finally I can get rid of the wordpress fucking stupid paragraph conversion which even can’t produce well-formed html. Now and tag is fully under my control.

  2. diego michel says:

    Hello, thanks for your plugin, just letting you know that it interfere with the plugin SyntaxHighlighter.

    Thanks.

  3. Regarding the additional paragraph tags that WordPress inserts, I get around that with the following:

    
    
    unmolested content goes here
    
    
    

    Since WordPress does not added anything after div tags, this allows you to use this plugin perfectly!

  4. I can’t figure out how to post HTML examples here, but bascically, you wrap the RAW tags in divs and WordPress leaves it alone. No extra p tags!

  5. Aaron Padoshek says:

    @Jason, that’s a nice workaround. I’m not a huge fan of adding extra markup to the page, but an extra div is better than the p tag that WP adds.

    Thanks for sharing!

  6. Brenda says:

    Does this plugin allow me to use javascript in my functions.php file?

    I want to code a mouseover for my header image. I have looked everywhere for advice on how to do this for a twenty-ten child theme, but haven’t found any, but I am assuming the code would go into the functions.php file and if not there, presumably in one of the other template files.

    Thank you

  7. White Shadow says:

    You don’t need this plugin to use JavaScript in your functions.php file – or any other theme file for that matter. WordPress doesn’t place any restrictions on the code used in template files.

    As for mouseovers – sorry, no idea.

  8. […] HTML 1.3, which shows up as “Raw HTML capability” when installed, is a big help if you prefer to have total control of the layout of the […]

  9. love this plugin. thanks.

  10. Eric says:

    Love the core part of this plugin, but I find (using WP 3.0.5) that any time I edit any post it now gets the four “raw” custom metadata fields added. This is distracting and redundant, given the checkboxes. In fact, this is so unexpected that some of my less sophisticated users are thrown by it. I am now trying to strip this functionality out of the plugin altogether, but for future versions, if there are any, I would suggest that this metadata be moved to somewhere that the regular WordPress does not display it or that there be an option to not include the per-post facility at all.

    Nice plugin! Thanks for sharing it.

  11. White Shadow says:

    Good idea. For the next version, I’ll change it so that per-post settings are stored in “hidden” custom fields.

  12. Eric says:

    That was fast! Thanks for the update.

  13. […] Raw HTML Plugin for WordPress | W-Shadow.com […]

  14. Thank you SO much!!! Now I can use as many templates as I want, and the code will be beautiful, and it will all look good. THANK YOU!!!!!!!!!!!!! :))

  15. Ausitn says:

    is it just me or did the Raw HTML plugin stop working after the most recent wordpress update? WordPress converted code, the older [raw] no longer works.

    My main issue is postings which I embed javascript no longer load. Any idea what changed?

  16. White Shadow says:

    I’m running WP 3.2.1 and, as far as I can tell, it still works here. For instance, the example code in the above post still correctly preserves newlines. So I doubt it’s completely broken. I’m guessing there’s probably a plugin conflict, or something server-specific, in your case.

    Could you show me a couple of pages where the [raw] tag no longer works?

  17. I have used this plugin prior in a different website with great success but that site has not been updated for at least 6 months for other reasons. Definitely an older version.

    The RAW HTML plugin was just installed at one of my newer sites on WP 3.2.1 that uses the Twenty Ten theme here – http://kangenwaterscamx.com

    My purpose was to eliminate the [RAW]&#038[/RAW]

    By activating the plugin –

    1. it adversely affects the sidebar widgets – they’re gone.

    2. In the area where I have javascript installed – the rest of the content is not rendered anymore after the swfobject.embedSWF( ) section.

    At this I temporarily disabled the plugin.

    Please advise.

  18. Sorry about the previous post.

    I had caching on and was looking at old cache. Deleted old cache and saw the latest.

    It now works fine!

  19. Jason says:

    When I add the raw tags in the html mode and update the page, view the page, the code works fine. But if I click over to visual mode it strips out the code and leaves the raw tags.

    I turned ticked off the options in the for the post.

    I can not disable visual mode as other admins need it to write post/pages.

  20. Jason says:

    btw, what is the difference between free and pro?

Leave a Reply