Last Updated: August 31, 2014

3 Ways to Add JavaScript to WordPress Posts or Pages

You might have modified your WordPress theme to add a JavaScript code but there are times when you may want to add JavaScript to a specific post or page. So, In this post I will explain you how to add JavaScript code to single WordPress post or page.

  • If you are running a self hosted WordPress blog than you can simple add the JavaScript code to your post through the built-in editor, just switch to HTML mode and paste the code.

Adding JavaScript in WordPress Posts and Pages

  • Alternatively, you can install a WordPress Plugin “Allow Javascript in Posts and Pages” which enables you to add JavaScript to blog posts and pages just by adding a simple short-code.
  • And if you don’t want to install an extra plugin to your WordPress Blog you can simply add a Custom Field (js) and paste the JavaScript code into the Value field. After that just add short-code in your post – [cf]js[/cf].

Adding JavaScript in WordPress using Custom Fields

Adding JavaScript in WordPress posts using Custom Fields

Also See: How to add PHP Code in WordPress Widget

Article by Tesur Rajan

Hey there, I'm Tesur Rajan owner of BubbleIndia. I write about things related to Blogging, WordPress, SEO and Social Media.