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.
Latest posts by Jamie (see all)
- Interview with Jungle Scout Founder Greg Mercer – The Million-Dollar Amazon Seller Tool - October 16, 2019
- Best Cheap Web Hosting 2019 – For Blog Owners on a Budget - October 12, 2019
- How to Start a Business: The Essential Step-by-Step Guide - October 8, 2019