Home » The Blog » WordPress » What are WordPress Shortcodes?

What are WordPress Shortcodes?

Any sufficiently advanced technology is equivalent to magic.

If you have a WordPress website, you've probably used, heard about, or even unknowingly used shortcodes. You may have noticed the shortcode widget in Gutenberg or offered by various plugins. But what the heck are shortcodes — exactly?

Shortcodes are basically little snippets of text in box brackets that tell WordPress to do certain things when that shortcode is present within a page or post. For example, you add a specified shortcode, and WordPress runs the background code.

Before shortcodes, you would have to actually write PHP code to create the layout or functionality you wanted. Now, with the help of talented developers, themes and plugins do all that for you. Then, you insert the provided shortcode, and the magic happens.

If you have a WordPress website, you have probably used the gallery shortcode at one time or another. It looks something like this: [gallery] .

This is the basic shortcode that WordPress inserts into a post when you use the Gallery block to display a gallery of photos that you just uploaded into WordPress on a page or post. You can add attributes such as size, columns, id, type, include, exclude, and others to further customize how the gallery displays

A Little Shortcode History

Introduced on March 29, 2008 in WordPress 2.5, the Shortcode API, is a simple set of functions for creating macro codes for use in post content. It enables plugin and theme 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.

Common examples of shortcode use are for embedding contact forms. Once your form is set up to your liking in the plugin's control panel, you then insert the provided shortcode into a shortcode block on the desired page and wallah. The form displays just the way you set it up. As a matter of fact, many form plugins have blocks that do the inserting for you.

I know I am dating myself, but back in the day before WordPress even existed, my Project Inquiry form would have required minimally HTML coding and a server-side CGI script that had to be configured as well! Now with just a couple of brackets and characters, anyone can add formatting to their site that would have been otherwise unavailable to non-developers.

Now can you see how shortcodes can make your life easier right? Rare is the theme or plugin developers that are not are using the WordPress Shortcode API to offer shortcodes that make formatting or using their products much easier.

Can you create your own shortcodes on the fly?

Specific themes and plugins provide the majority of shortcodes. For example, the Gutenberg Editor that was added with WordPress 5.0 includes blocks that handle shortcodes. When converting content to Gutenberg, with the “Convert to Blocks” option, existing shortcodes will be converted into a shortcode block.

However, WordPress's built-in default set of shortcodes for those of you still using the Classic Editor plugin are there for your use. These shortcodes also have attributes that you can add to the shortcode to further customize to your needs. The Gutenberg Editor that was added with WordPress 5.0 includes blocks that handle much more.

Shortcode use and integration vary by theme, by developer and by plugin. When investigating new themes, within the theme demo you may find a menu tab “Shortcodes” to see what customized shortcodes will be available for your use.

An example of a theme that creates a website dependent on shortcodes is Divi (aff) by Elegant Themes. ET uses shortcodes extensively in their Divi All-In-One WordPress Theme & Visual Page Builder. While this approach makes designing your website uber easy for non-developers if you choose to use Divi no longer — you'll have to remove all those shortcodes, which can be a complicated process.

Example Functionality of Shortcodes

Other examples of how shortcodes are used and integrated via themes and plugins:

  • Author Info
  • Buttons
  • Column Layouts
  • Content Boxes
  • Custom Icon Lists
  • Corporate Pricing Tables
  • Testimonials (aff)
  • DropCaps
  • Toggled Content
  • Tabbed Content
  • Slideshow
  • Image Slider
  • Easy Tooltips
  • Social Media
  • Quotes
  • Password Protect Your Content

There is a varied selection of Shortcode-related plugins for you to choose from and use on your site in the WordPress plugin repository. With the help of shortcodes, you can now customize your site even further — without having to know any actual code. It's sort of like magic.

At your service,

WordPress Consultant Judith