Contact Us

Shortcodes are small pieces of a specific code that permit you to perform different tasks with little effort. They first appeared in WordPress 2.5 to allow users execute specific codes inside your different WordPress pages, posts, widgets, and plugins without directly writing code. Thus, in one single line, you can create objects or embed files that would typically require writing a large amount of code. As an example, if you wanted a shortcode that embedded a video, it would likely look like this:

[video]

WordPress comes installed with numerous built-in shortcodes. These include options like audio, embed, caption, gallery, and as mentioned, video. The Shortcode API allows others to be added through various plugins.

Shortcodes may also include attributes. For example, the built-in WordPress video shortcode is able to accept a src attribute:

[video src="video-source.mp4"]

When writing a post, there may be a time that you prefer using the text of a specific shortcode. This requires you set up the ability to escape the command using a set of double brackets. As an example, if you prefer to display the video shortcode text instead of the video itself, you would type this:

[[video]]

Shortcodes make adding features to your WordPress website easier. Functionalities that usually require much more code, such as galleries and videos, are easily added straight into the page or post in the exact spot the user chooses for them to appear.

← Back to Glossary