Client Side

All the fancy frizz

Embedding JavaScript in WordPress Posts

Written by: Peter Fisher on September 21, 2012
Tagged under:
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

WordPressSome of my posts such as the wordCounter jQuery plugin include external JavaScript files via a condition in the themes header file. This is demonstrated in a previous WordPress tutorial. In answer to Anands question about triggering JavaScript functions from a within a page, I’m going to explain how to quickly embed a script within a post rather than include it the head tag.

Now you can simply click on the html tab in the post editor and write raw JavaScript into the post but as soon as you flick back to visual mode, the tag blocks will be changed into ASCII characters which will render your script unusable.

The best way to do embed JavaScript into your WordPress posts is to use a plugin  such as Jinx. This little gem will include the JavaScript under the contents of your post.

Use Jinx to include JavaScript in your WordPress posts and pages

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Peter Fisher is a web developer working in Gloucester UK. Founder of the digital agency Websomatic, author of this blog and the HowToCodeWell Youtube channel. Peter has over ten years of web development experience under his belt

Read all about Peter Fisher

Leave a Reply

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