
As a person who begin to explore WordPress platform not much time ago, you probably try to learn some handy tricks to make your work in WP much easier. One day you may find out about such thing like “shortcode”. It’s a long PHP function in short line, which you can paste in your post to save your time. It looks something like this:
[shortcode_name=shortcode_value]
But you may meet shortcode in PHP code notation. The difference is the last one is line of PHP code, which already includes ready shortcode, that is made by your plugin. You can paste this code in any place in your PHP code, for example header or footer or almost to the PHP code of your theme to show information on every page of your site.
There are a few ways to use this excellent tool.
-
Just use shortcode, generated by your plugin
Many plugins generate their own shortcodes and so there is no need to make changes to
functions.php
file. You can find this code in your plugin or plugin’s documentation. So just paste this code into your page text editor or post and enjoy it! In the case shortcode doesn’t work contact your plugin developers or their support service to solve this problem. -
-
Make your shortcode using one of shortcode generators, like Generate WP tool. Here you just need to enter some attributes to PHP code to the template on that site and this service will generate a shortcode with every parameter you noticed. This service has templates for such items like video, image, “bold text”, “link-to-post” and “recent posts”.
-
Use one of the WP plugins
One of the most popular plugins to create your own shortcode is Shortcodes Ultimate, which provides incredible collection of shortcodes that are easy-to-use. Another one plugin, Shortcode Maker has the large quantity of shortcodes and even features to write your own PHP code. Also you may try the fine collection of Shortcodes by Angie Makes, that includes most often used elements on the site: grid system, tabs, masonry, images, buttons, icons and so on.
-
Use one of the default WP shortcodes
A very few users know about this tool. Yes, you can add video, gallery, audio, captions, embed items to your site using just one template from official site. There are not many parameters you can customize for them, but if you need simple and quick solution – these features will be enough.
Generate your own shortcode personally
-
-
Explore one of prepared shortcodes
You can find a lot of examples of ready shortcodes from different plugin developers. But be careful: most of developers advice you to paste their php-shortcode directly in
functions.php
. That’s not a good idea, especially if you’re a newbie in coding. It will be better to create new PHP file, for examplemy_shortcodes.php
inside “includes” directory (where you will put in all those “shortcodes”) and insert to yourfunctions.php
file next string:include 'my_shortcodes.php';
This operation will unload your
functions.php
and make PHP code more readable. -
Write your shortcode
Sure, you must know PHP to do this. But even if your PHP knowing is not great you can write a shortcode using one of the articles with detailed review, for example this one.
Be careful
Shortcodes is very simple tool to use. And they make your site creation so faster and orderly that you’ll cannot build your site without that ones. Depending on your experience, you may choose the most suitable way to use them, even if you have zero coding level. So, let’s use shortcodes to make your blogging easier, to save your time and make your site look more beautiful!
Hi! Once i headr about turning on wp debug mode on the forum. Very interesting method