All Free Web Resources for Designer

4 min read

How to Use WordPress’ Built in Short Codes and Registering Custom Ones


Beautiful design aren’t the only things that make your themes great. Each theme also comes with a powerful set of tools, and making each theme as userfriendly and versatile as possible. Many premium wordpress themes using more advanced worpress’ techniques, one of which is  “shortcodes”.

What is the WordPress’ shortcodes

Shortcodes have been introduced in WordPress 2.5. They’re hooks which allow you to call a php function simply by typing something like [shortcode]. It is a great way to save time on repetitive tasks. Just read on to find out how to use them.

It enables plugin developers to create special kinds of content (e.g. forms, content generators) that users can attach to certain pages by adding the corresponding shortcode into the page text.

The Shortcode API makes it easy to create shortcodes that support attributes like this:

[photogallery id=”123″ size=”medium”]

How shortcodes works

To create a shortcode, you first have to create a php function. Let’s start with a basic one. Append it to your functions.php file.

Shortcodes are written by providing a handler function. Shortcode handlers are broadly similar to WordPress filters: they accept parameters (attributes) and return a result (the shortcode output).

This is only sample how we can make a good deal with WordPress shortcode. We can made more complicated shortcode if we need it.

function webdesignhot() { return ‘Have you checked out <a href=””>Web Design Hot</a> today?’; }

Once you created your function, you have to use the add_shortcode() function. paste this code just after your function on the functions.php file from your theme:

add_shortcode(‘wdh’, ‘webdesignhot’);

You’re now able to use the wpr shortcode. To do so, paste the following line of code on the editor (in HTML mode) while writing a post:


This short code will output the “Have you checked out Web Design Hot today?” message.

You might also like: