How To Allow JavaScript Inside WordPress Blog Posts And Pages ?

WordPress Plugin Repository has a powerful plugin that allows you to use JavaScript inside your blog posts and pages simply by using shortcodes. Allow Javascript in Posts and Pages is a an old WordPress plugin but still it works fine without any conflict in the latest version of WordPress i.e. WordPress3.5.1. The plugin lets you add Javascript inside WordPress posts and pages, while retaining HTML tags and other functional script. It strips away auto generated WP <p> and <br/> tags but at the same time the plugin allows addition of your own <p> and <br/> tags by using [p] and [/p] or [br/] or [a href=’void(0)’]link[/a].

Installation & Usage:

Install and activate Allow Javascript in Posts and Pages. After activation you may start using its simple shortcode [js].code.[/js]

For adding Javascript code in your post or page you have to simply place your Javascript code inside shortcode tags as shown below:

For example: a simple alert


Given code will cause a popup after the page loads

Additionally, should this code not be working (for example a missing “;”) simply just change the [js] to be [js debug=1]

     [js debug=1]

After activation visit your Dashboard -> Settings -> Allow JS in Posts, where you will find all important information on this plugin usage, tips and examples

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.