Many plugins offer the ability to use their functionalities via shortcodes.
You can use shortcodes defined by plugins (and rely on them, which I’ve found many times too risky, especially when updating the plugin).
The alternative is to start using your own shortcodes, and have full control over their behavior.
Before adding a first shortcode, you’ll need to make your blog ready, but it should take no more than 15 minutes.
Setting up own shortcodes
1. Create a separate file for shortcodes
Shortcodes are nothing more than WordPress functions. You can add them to functions.php file, but it’s much better to collect them in a separate document.
To do that, go to your WordPress theme’s folder and create a document named shortcodes.php. You can do that this way:
- duplicate any of the existing php files, and rename it to shortcodes.php,
- open shortcodes.php, remove all the text and save the clean file – it’s where we will add and store all the shortcodes.
2. Register shortcodes
To let WordPress know there are functions stored in a separate file, open functions.php and simly add this piece of code (remembering this rule):
include('shortcodes.php');
Done. Now your WordPress blog is ready to execute your own shortcodes.
• • •
When you edit your WordPress files, it’s highly recommended to:
- do it on a test theme, not the active one,
- run html and feed validation, before you copy the files to the active theme.
More on WordPress shortcodes:
[pi-archive number=5 tag=”shortcodes” ]