Add custom scripts to WordPress header and footer through Customizer

We often need to inject some custom scripts to our WordPress websites. From Google Alalytics code to custom tweaks, it's really handy to have the ability to insert some scripts which lacks in WordPress. Though there is a way to add additional CSS, you can't really add any scripts without editing theme or plugin.

Using Plugin

You can add custom scripts to your WordPress websites using a plugin and perhaps it's the best and safest way if you trust the plugin. When you don't need the scripts, you can take off them and disable the plugin.

There are few plugins in WordPress repository but none of them using Customizer feature. So you need to add them from WordPress Dashboard, save script and check back the pages to test the functionality.  Since I often need to add some scripts to add interactivity or custom features, I felt it should use the Customizer so that it could be tested on the fly. So I built a fresh new plugin for this and released for free on the WordPress repository. You can check Custom Header Footer Scripts for Customizer

Download WordPress Plugin

Using this plugin, you can add multiple scripts to header or footer that might be Google Analytics, Facebook Like Box, YouTube Subscribe button, Pinterest integration and anything. So give it a try and let me know if you have any feedback. It's also available on Github

Click to enlarge
Click to enlarge
Click to enlarge

Using Custom Code

If you want to get your hands dirty or want to add the functionality to your theme or plugin, here goes the necessary function to add this to either WordPress header or footer.


Add to WP Footer

You can add this to your Child Theme's functions.php or within your theme or plugin.

Revamped my personal website

I have been developing number of websites in past couple of years but couldn't manage to redesign my website since then. I believe that's a common story of most of the developers out there. Finally managed to re-design my personal website which was long due.

It was raining cats and dogs for couple of days (at weekend) and I felt boring staying at home all day long. So decided to do something interesting (and not so boring) and here is the result. You can check my design at my portfolio site.

Also deleted all my old posts from the blog (those were obsolete) and starting fresh! I have used my new theme Flexia to design the blog and hope to write regularly.

Flexia - A modern lightweight and versatile theme for WordPress