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 Spencer (see all)
- How To Make Money As A Kid In 2022 – 6 to 16 Years Old - January 1, 2022
- 38 Great Examples Of The Best Gaming Blogs – 2022 Edition - November 25, 2021
- How To Find The Best Cheap Web Hosting In 2022 – Low Cost Hosting For Bloggers & Businesses On A Budget - October 12, 2021