Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

What is: Shortcodes

Shortcodes in WordPress are little bits of code that allow you to do various things with little effort. They were introduced in WordPress 2.5, and the reason to introduce them was to allow people to execute code inside WordPress posts, pages, and widgets without writing any code directly. This allows you to embed files or create objects that would normally require a lot of code in just one single line. For example, a shortcode for embedding a video might look like this:

[[video]]

They can also come with attributes. For example, the built in WordPress video shortcode can take a src attribute:

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

WordPress comes with several that are built in. These include audio, caption, embed, gallery, and video. Others can be added by plugins using the Shortcode API.

Sometimes you may want to use the text of a shortcode in a post. To do this you have to escape it using double brackets. For example, if you want the text of the video shortcode to display rather than an actual video you can do the following:

[[video]]

Shortcodes simplify the addition of features to a WordPress site. Galleries, videos, and various other functionality would require a lot of code editing. By using shortcodes the HTML and other markup is added dynamically directly into the post or page where the user wants them to appear.

Additional Reading

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!