Home News What Are WordPress Shortcodes

What Are WordPress Shortcodes

WordPress shortcodes act as shortcuts that allow you to embed elements into a post or page quickly. These usually consist of a single line of code within square brackets, such as 

[exampleshortcode], for example. This code will display a predetermined feature on the front end of your site.

WordPress first introduced shortcodes with the release of the Shortcode API. This enables users to easily add engaging elements to their posts and pages, such as Google Maps or Facebook “Like” button.

There are six default shortcodes in WordPress:

  • caption: wraps captions around content
  • gallery: shows image galleries
  • audio: embeds and plays audio files
  • video: embeds and plays video files
  • playlist: displays a collection of audio or video files
  • embed: wraps embedded items

You will also come across two basic types of shortcode formatting – self-closing and enclosing. Self-closing shortcodes can stand on their own and do not need a closing tag, such as the 

gallery or 

video shortcodes above.

Meanwhile, enclosing shortcodes wrap around the content you want to modify and require you to close the tag manually. For example, you can embed a YouTube video by wrapping the URL in 

embed and 

/embed tags:

“In a world older and more complete than ours they move finished and complete, gifted with extensions of the senses we have lost or never attained, living by voices we shall never hear.”

— Olivia Rhye, Product Designer

READ MORE