WordPress is well-known for being a flexible content management platform that offers simplicity, and takes away the lengthy process of having to write code and stylesheets to create something beautiful. You can see this simplicity in action every time you open the Add New posts page; the WordPress content editor and its usefulness has grown exponentially over the years, but some features are still to be relied upon with 3rd party plugins.

Shortcode WordPress
Image Source: laurentvalentinjospi0 – Pixabay.com / License: CC0 Public Domain

Shortcodes are one such feature. With shortcodes – tiny code snippets – you can achieve a number of things related to displaying and embedding content. The main goal of shortcodes is to allow “compiling” code within a WordPress content post, a page, or a sidebar widget, without the need to write any actual code yourself. Embedding a YouTube video might take many lines of code, and help of iframes, whereas with a shortcode you can just do:

[video mp4="source.mp4" ogv="source.ogv" webm="source.webm"]

The above shortcode will embed your video of choice in three different formats to reflect the browser capabilities of executing HTML5 code snippets. And there are many different custom settings you can use as well.

How to create your own custom WordPress shortcode

Of course, the first thing you should do after learning about shortcodes is to experiment and create one of your own. The following example is a simple one, where you can create a shortcode for using the “blockquote” WordPress tag to let your readers know about your social networks and how they can follow you.

First of, you should open the functions.php within your main WordPress theme. After doing this, find a place where you can put the following code:

function get_blck($atts) {
  return '<blockquote>
Please follow us on social media: <a href="https://twitter.com/" target="_blank">Twitter</a>, <a href="https://facebook.com/" target="_blank"&  gt;Facebook</a> and <a href="https://plus.google.com/" target="_blank">Google+</a>.

The code execution here is pretty basic, whatever is inside of the return ‘ ‘; field will be possible to execute under the [blck] shortcode. As it stands right now, you have the shortcode ready to go, but you still need to actually add it to your WordPress system by using the WordPress API. Underneath your shortcode code, put the following line of code:

add_shortcode('blck', 'get_blck');

What this will do is that it will call the actual function you created, and assign it a special shortcode name, in this case [blck]. Any post you write from the moment you save your new functions.php file is going to be able to display your newly created shortcode. This can be used in relation to many different techniques, for example if you wish to portray AdSense ads using a shortcode, or if you would like to execute custom buttons for different occasions. Shortcodes give you a lot of flexibility in this matter.

Apart from writing your own, in recent years there has been a huge influx of specifically built shortcode plugins that have a lot of pre-built templates already, saving you time from having to create your own. Lets take a look at the two of the most popular shortcode plugins.

Shortcodes Ultimate Plugin

Shortcodes Ultimate Plugin
Image Source: Screenshot – WordPress.org

With more than 400,000 active installs, this shortcodes plugin will cater to a number of needs and situations. Shortcodes Ultimate gives its users a list of shortcodes that fall under the categories of: tabs, buttons, sliders, responsive content, and so much more. The design is sleek (CSS3 powered) and will look great on any type of blog/website, and all shortcodes can be edited to your own specific needs/requirements.

Easy Bootstrap Shortcode Plugin

Easy Bootstrap Shortcode
Image Source: Screenshot – WordPress.org

You can’t really go wrong with Bootstrap, which is why we feel it can be an essential part of building content posts and pages that are optimized with the latest web technology gadgets for maximum performance. Easy Bootstrap Shortcode will give you access to several different features, including: tabs, lists, notifications, tooltips, progress bars, buttons, icon headings, tables, responsive content, and a lot more.

It’s easy to use, and comes packed with Font-Awesome & Glyphicons Icon Fonts (more than 500+ of them), and there is plenty of configuration access to make sure that your shortcodes fit perfectly with the pages/posts you’re building.