- Internet & the Web»
- Web Page & Web Site Development
One of the frustrating part of using Wordpress, including the latest version 3.5, is that it doesn't allow you to embed scripts, other HTML tags or PHP codes just as they are. When you create a post or a page, if you add certain HTML like <script>, in TEXT tab, you will notice in the HTML tab, Wordpress automatically strips off the <script> tag and certain types of HTML tags like those. While the intention for disabling these codes through the visual editor is for security purposes, it does present inconvenience for those who'd actually like to embed HTML codes or scripts or even PHP codes they know are safe. Now if you need to add static HTML, or PHP codes you can add it through the template files (in administration -> Appearance -> Editor) but that won't add page-specific or post-specific HTML code or even PHP code. After searching through many plugins, I finally found a plugin that does the trick.
The Solution - Shortcodes Pro
The plugin is called Shortcodes Pro. Despite the name "Pro", it is completely free plugin. You do not have to pay to use this. You can get it here: https://wordpress.org/extend/plugins/shortcodes-pro/. Install it to your Wordpress by going to your administration -> Plugins -> Add New -> Search for "Shortcodes Pro". The first result should be it, the plugin creator is "sksmatt", that should help you locate the plugin.Though it states that it is only compatible up to Wordpress 3.5-beta-1, fortunately it has been working without a flaw in my Wordpress 3.5 release. The only downside is I wasn't aware initially how to use the plugin. It's very simple. Here are the steps:
Quick Steps to easily add HTML or PHP
1. After you install Shortcodes Pro, you should see on the admin panel on the left side, a new tab "Shortcodes Pro".
2. Hover your mouse over "Shortcodes Pro" and click on "Add New Shortcode"
3. Name your shortcode something simple
4. For Behavior, select "Insert custom code"
6. Just insert your code and hit "Publish".
7. Now on your post or page, either in the TEXT or HTML tab, it doesn't matter just insert the following code replacing SHORTCODENAME with well the shortcode name you made.
Example of Shortcode Pro code in your post or page
Extent the Use
Now there are many more uses of this, including adding shortcode button to the TinyMCE toolbar as well as wrapping your entire content with a HTML tag and much more. The following video below will teach you those extra features.
Shortcodes Pro Video Tutorial
See how I used Shortcodes Pro
To embed the hubpages article widget on my wordpress, I had to use Shortcodes Pro. You can see that in use here: http://stanley.thepharmacopedia.com/papers-and-articles/