What are Shortcodes in WordPress?
WordPress shortcodes are an excellent way to add more style or advanced elements to your content. If you’ve been using the platform for quite some time, then you’ve probably used shortcodes in the past without even knowing it. If you’re new to the platform, then you’ll want to get familiar with them because they are incredibly useful.
Let’s start with the basics.
What Are WordPress Shortcodes?
To put it in layman’s terms, shortcodes are essentially shortcuts for doing various things in WordPress. You input a simple line of text and WordPress converts it into an advanced function. It’s kind of like when you text a smiley using code and your smartphone or IM application converts it into an actual emoticon.
With a shortcode you can do things like place an advertisement somewhere in your content, include an image gallery or share a YouTube video. However, one of the most common uses for shortcode is to add various style elements to a page such as buttons, columns, design boxes and more.
How Do Shortcodes Work?
The traditional way to use shortcodes is to include the full code in your functions.php file on the backend of your site. On the front end of the site, when you use the related shortcode in your content, the platform automatically knows to execute the appropriate action. This is a little more difficult to set up and requires a bit of programming knowledge, specifically in PHP.
The easier way to implement shortcodes on your site is to install a plugin. In fact, most plugins use shortcode by default to get a specific feature working. For example, a sliding gallery plugin may ask you to include the [slide-gallery] shortcode where you want it to appear.
By default, WordPress has a pretty extensive list of shortcodes you can use without installing any plugins or altering the functions file at all. Here are the highlights:
- YouTube video: Paste the URL of a YouTube video on a line by itself, not hyperlinked.
- Instagram image or video: Paste the URL of an Instagram photo on a line by itself, not hyperlinked.
- Tweet: Paste the URL of a specific tweet on a line by itself, not hyperlinked.
- SlideShare presentation: Choose “embed” on SlideShare, choose your settings, and grab the generated shortcode.
- SoundCloud audio file: Choose “embed” on SoundCloud, choose your settings, and grab the generated shortcode.
There are many other types of shortcodes in your WordPress install by default.