Custom HTML Widget Changes in WordPress

Last week I was asked by a client if I could help them put the Mailchimp newsletter signup form on their site. They had been trying for a while and they couldn’t get the form to appear at all. “No problem” I said, think that this would be a doddle. A couple of hours later I was pulling my hair out as I tried everything I could to get it to work.

Finally I did the inevitable Google search and discovered the at some point recently the custom HTML widget had been changed and that “some HTML tags like script, iframe, form, input, and style are not available.” This referred to WordPress.com installations but I am guessing that it applies to WordPress.org installs too as that was my situation.

Another search didn’t yield any quick solution for me and so I rolled up my sleeves and wrote a custom plugin to get round it. This was incredibly simple to do and the code is below – this needs to go into the wp-content/plugins folder. Remember to change the ‘Your raw HTML here’ bit!

<?php
/*
Plugin Name: Output Raw HTML
Plugin URI: https://www.spokenlikeageek.com
Description: Spits out raw HTML 
Version: 1.0
Author: Neil Thompson
Author URI: http://nei.lt
*/


add_shortcode( 'slagrh', 'slag_raw_html' );

function slag_raw_html( $atts ) {

  $output = 'Your raw HTML here';
  return $output;

}

To use use put [slagrh] wherever you want the raw HTML to appear and WordPress will oblige.

Quite why this should be necessary I do not know but there you go. Hopefully it will save someone else a load of time or, if you have a more elegant solution, please let me know in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *