Adding JavaScript to a Wordpress Post

Adding JavaScript to a WordPress Post

JavaScript and most blogging platforms are two things that don’t always mix.

Programmer wo In the past major social networking communities allowed users to add JavaScript to their blog posts and profiles not realizing that a major security risk was being created. After ending up offline because of these breaks in security sites like stopped allowing the use of JavaScript on their pages. This has caused a bit of frustration for those who host their blogs for free on the WordPress site, and for those who use the WordPress platform on their own server. While hosting WordPress on one’s own server allows for a lot more flexibility the software’s’ built-in security features still make using JavaScript difficult. Inserting JavaScript directly into a templates sidebar coding can sometimes cause layout problems and errors. Recent upgrades in the WordPress 2.0 series now allow users using dynamic sidebars to add JavaScript code in to text box widgets. This feature makes it possible to add Google Adsense, MyBlogLog, and other JavaScript codes into the sidebars but doesn’t help when it comes to adding JavaScript directly into an individual WordPress post. Luckily several designers who use WordPress have developed plugins to help get around this limitation. After trying several with varying results the plugin currently used at my WordPress powered site, is the Inline JavaScript Plugin developed by Volcano at (site is multi-lingual). The plugin consists of one php file, inline-js.php, which is copied into the wp-contents/plugin directory. After the plugin is placed into the directory and activated it is now possible to insert working JavaScript directly into a post using the following code (after removing excess spacing): [tp_code][inline] lt; script type= ” text/ javascript ” gt; lt; the JavaScript you want to insert gt; [/inline] [/tp_code]   If you would like to add any text after your JavaScript enter a line break code < br > followed by your text. The following is an example: [tp_code][inline] lt; script type= “text/ javascript ” gt; lt; the JavaScript you want to insert gt; [/inline] [/tp_code]   The Text You Want To Enter This code was used in WordPress version 2.3.2 with the Visual Editor turned off. The editor can be turned on and off by accessing the User Profile in the “Options” folder of the WordPress dashboard.
Related Posts