WordPress Shortcodes

wordpress-shortcodeWordPress Shortcodes as the name suggests, is a very short code which help us to do useful things very easily. Shortcodes are placed in square [ ] brackets. Hence when WordPress sees these shortcodes, it understands that these shortcodes should be replaced with some dynamic content. These dynamic content is created by a PHP function. These shortcodes run when the content is loaded.

You are able to create your own WordPress shortcodes within the theme you are using. And don’t have to use the complicated markup every time but use the shortcode instead. There are some available WordPress Shortcodes. But before that let us get to how we can create a short code. This would require you to have a basic knowledge of PHP.

Creating a simple WordPress Shortcode

There are 2 things you need to create a WordPress shortcode

  1. WordPress Shortcode Handler Functions (Callback Function)

    This function will be called whenever WordPress encounters the shortcode. It accepts parameters as input and returns the result as an output. For eg. let us assume that we are creating a shortcode [weblogoptions]. Primarily we need to create a callback function which will run when the shortcode is used. We can place this handler function either in functions.php or a separate file (eg. shortcodes.php – We can place all the shortcode functions there) and include that file in functions.php function weblogoptions_function($parameters) { return 'Something'; }

  2. Registering the WordPress Shortcode

    In this we are telling WordPress that this fuction is a shortcode. When WordPress sees the shortcode [weblogoptions] it immediately calls the function weblogoptions_function function register_weblogoptions(){ add_shortcode( 'weblogoptions', 'weblogoptions_function' ); }

Available WordPress Shortcodes

These are the WordPress shortcodes which are commonly used.

Image WordPress Shortcodes

  1. [ gallery ] – used to insert an image gallery into a page or a post.
  2. [instagram] – used to embed an image from Instagram
  3. [flickr] – used to embed an image from Flick

Video WordPress Shortcodes

  1. [youtube] – to embed video from YouTube
  2. [vimeo] – to embed video from Vimeo
  3. [dailymotion] – to embed video from Dailymotion
  4. [flickr] – to embed video from Flickr

Audio WordPress Shortcodes

  1. [soundcloud] – embeds a soundcloud audio
  2. [spotify] – embeds music from spotify

Documents WordPress ShortCodes

  1. [scribd] – used to embed a scribd document
  2. [slideshare] – embeds a presentation from slideshare
  3. [googleapps] – embeds a document from google apps

Miscellaneous WordPress Shortcodes

[archive] – used to display the archives of your blog [display-posts] – used to display posts [contact-form] – displays a contact form in your page

Pros & Cons of using WordPress Shortcodes


  1. These are easy to use. You don’t have to write the PHP code every time. Use can just use the shortcodes instead.
  2. Saves a lot of time and increases efficiency


  1. WordPress shortcodes are dependent on the theme or plugin.
  2. Use shortcodes only when really necessary, as there would be lines and lines of code running in the background and it could be overused.

Speak Your Mind