If you’ve been using WordPress for a little bit, you might’ve come across the term “shortcode.” While shortcodes are an exceptionally helpful feature in WordPress, the name isn’t very self-explanatory (at least at first). That might have you wondering … what are shortcodes in WordPress?
In a nutshell, a shortcode is a small piece of code, indicated by brackets like
[this], that performs a dedicated function on your site. You can place it just about anywhere you’d like, and it will add a specific feature to your page, post, or other content. For example, you can use shortcodes to display galleries, videos, or even playlists.
What are shortcodes in WordPress?
Since WordPress is an open-source platform, you can customize it in any way you’d like. This includes adding entirely new code to your site. But if you aren’t a developer, adding code by yourself isn’t really feasible. That’s where shortcodes come in. You can use shortcodes to achieve the same effects, without needing to know anything about the underlying code.
So, what are shortcodes in WordPress? They are truncated bits of code that look something like this:
Most shortcodes make it very obvious what they do. For instance, the above code adds an audio file to your site. To use it, you’d paste it into a post or page, and would immediately be able to see it on the front end. Behind the scenes, the shortcode is telling WordPress to execute a longer section of code within one of your site’s files – but that process requires no further input from you.
At this point, you may be wondering more than just “What are shortcodes in WordPress?” You may also be interested to know where these shortcodes come from, and how to find them.
There are several plugins that are built into WordPress by default, which we’ll discuss shortly. But beyond that, many plugins also add their own shortcode(s), which you may need in order to make them work.
For example, our Intergeo Google Maps plugin includes shortcodes you can use to place your map wherever you’d like on your site. You can even add dozens of new shortcodes via dedicated plugins (again, more on this later).
How do you use shortcodes on your WordPress website?
Now that you can answer the question “What are shortcodes in WordPress?”, it’s time to discuss how to actually use them. To start, let’s take a quick look at the shortcodes that are incorporated into the platform by default:
- audio: Embeds audio files and enables playback.
- caption: Lets you wrap captions around content.
- embed: Makes it possible to set maximum dimensions for an embedded item (such as an image or social media post).
- gallery: Adds a customizable image gallery to your site.
- playlist: Creates an audio or video playlist.
- video: Places a video file that can be played back.
Like any shortcode, these can be simply copied and pasted directly onto your site. Generally, they’re placed into a post or page. However, they can go in any location where you can add code through the WordPress editor, such as a custom post type or a text widget.
You can place a shortcode using either the Visual or Text editor:
We’ve used the Text editor in this example, because by switching back over to the Visual tab, you’ll see the new feature in place. Since we just placed the gallery shortcode in a post, we can now edit it to include whatever images we’d like:
Of course, it’s worth mentioning that not all shortcodes are this simple. In fact, some can even be customized to alter the way they work. For example, our WP Product Review plugin lets you create a shortcode that displays your reviews exactly how you’d like them to appear. Most developers who include these kinds of shortcodes with their plugins offer documentation to help you use them.
Generally, you make your customizations using things called “parameters” that look something like this:
Finally, you can also create your own shortcodes from scratch if you’re feeling ambitious. This is actually simpler than it sounds, and you can find plenty of guides to walk you through the process.
Can you add more shortcode options to your site?
The short answer to the above question is “Yes!”. You can add more shortcodes to your WordPress site without going through the trouble of creating them yourself. As we briefly mentioned earlier, there are plugins that offer a whole suite of new shortcode options. All you have to do is install the plugin and check out its documentation to see what new choices are available.
For example, Shortcodes Ultimate is an excellent free plugin that adds more than 50 shortcodes to your site. Some provide simple features such as headings, lists, or quotes, while others offer more complex functionality like sliders, carousels, and animations. Placing these shortcodes is easy, since Shortcodes Ultimate adds a new button to the WordPress editor that simplifies the process. There are even optional add-ons if you want more choices.
You can even find premium shortcode plugins – Vision is a perfect example. For $25, this plugin gives you access to over 100 shortcodes, many with various customization options. You can create buttons, pricing boxes, social media icons, and much more. Plus, you’ll get access to professional support.
Whether you choose the free or premium route, it’s a smart idea to at least find out what’s available. With the right shortcode plugin, the work of creating content and building your site can be dramatically simplified.
Is there anything “bad” about using shortcodes?
Nope! There’s nothing wrong with using shortcodes. There is one thing you should remember, though:
If you use shortcodes that come bundled with your theme, or as part of a plugin, those shortcodes will stop working if you ever switch themes or disable the plugin.
This isn’t a “bad” thing – it’s just something you should be aware of so that you don’t get surprised down the road!
What are shortcodes in WordPress? They make your life easier.
Shortcodes are useful because they offer a way for you to make specific tweaks and customizations on your site, even if you aren’t a coder. Many plugins also require the use of shortcodes, so it’s important to understand how to use them correctly.
In this article, we’ve answered the question: “What are shortcodes in WordPress?” By now, you should understand that these little bits of code can be placed nearly anywhere on your site, and will work automatically. You can use WordPress’ default options, and even install a plugin such as Shortcodes Ultimate or Vision to get more shortcode choices.