What is: Shortcode

Just as you might imagine, a shortcode is a tiny snippet of code that can be used to perform a number of functions. Shortcodes were first invented for WordPress version 2.5 and have been included in all newer versions of WordPress.

A shortcode is, at its heart, an easier way to activate a function. For example, the shortcode [ video ]

is much easier to type and remember than the lengthier PHP code sequence used to embed a video into a page or a post.

Some people refer to shortcodes as “macros” because they are preset commands that, when activated, execute a prewritten series of commands.

WordPress comes with several shortcodes already built in, including:

[ video ]

You can also create your own shortcodes or load more via a plugin.

Shortcodes are primarily used for people wanting to perform simple commands inside of a post, page, or widget without having to write out the code directly.

If you want to use a shortcode inside of a post, first, make sure that you’ve activated Text (instead of Visual). Then, insert the shortcode. But if you want to display the text of a shortcode inside a post, you’ll need to wrap it in double brackets. For example “[video]” is what you’d need to type in the text editor in order to show the text in your post.

Shortcodes can also come with attributes. For example, you can write [ video src=”mycoolvideo.mp4″ ] in order to embed the video “mycoolvideo.mp4” into a post.

Note: Shortcodes can also be used in widgets starting with WordPress version 4.9.

The following two tabs change content below.

Jamie Spencer

My name is Jamie Spencer and I have spent the past 10 years building money making blogs. After growing tired of the 9-5, commuting and never seeing my family I decided that I wanted to make some changes and launched my first blog. Since then I have launched lots of successful niche blogs and after selling my survivalist blog I decided to teach other people how to do the same.