How to Add Dynamic Content with Shortcodes

Disclosure: This post may contain affiliate links. Purchasing a product through one of these links generates a commission for us at no additional expense to you.

Here’s the problem:

You want to include a form, slider, or another dynamic element in one of your posts or pages. How do you do it?

Luckily, the WordPress developers created a simple solution called shortcodes.

What are shortcodes?

Subscribe to Compete Themes on Youtube

Shortcodes are simple codes that you can add into the post editor to include dynamic content from a plugin.

For instance, the MetaSlider plugin lets you create and customize image sliders in your WordPress dashboard. After you’re done making your slider, you can output it on your site using the widget or a shortcode.

Almost every plugin that creates content will give you both a widget and shortcode to use.

This is an example of what a shortcode provided by the MetaSlider plugin looks like:

[metaslider id=”267″]

Shortcodes are always wrapped in brackets and begin with a name assigned by the plugin. In this case, that name is “metaslider.” Then there are a series of parameters. The shortcode above has one parameter called “id” which is set equal to 267.

WP Site Partner logo

Too busy for WordPress? We can help.

WP Site Partner is our new maintenance and customization service for busy WordPress users.

Learn More

How to use shortcodes

Using shortcodes is very easy.

Regardless of what plugin you’re using, you’ll be provided with the shortcode somewhere in the plugin’s interface. For instance, WPForms lists the shortcode for displaying each form in the All Forms menu.

WP Forms Shortcodes

Shortcodes can simply be copied & pasted into the post editor. For instance, here’s what our contact page looks like in the WP dashboard:

Contact Page Editor

See how the shortcode is visible?

The form itself won’t render in the editor. However, if you visit the contact page on our site, you’ll see the form displaying instead of the shortcode found in the editor.

Contact Page

If you’re editing a draft, rather than a published page/post, you’ll need to save the draft before the shortcode will run in the preview.

Tons of plugins use shortcodes so you’re sure to come across them at some point if you haven’t already.

Conclusion

While shortcodes aren’t perfectly intuitive because of their limited ability to preview content in the editor, they do work well for adding dynamic elements inside of posts and pages.

Once you know you just have to copy & paste them into the editor, they become very easy to work with. Some plugins even have extra parameters for their shortcodes you can use to customize the output.

Ben Sibley
Ben Sibley
This article was written by Ben Sibley. He is a WordPress theme designer & developer, and founder of Compete Themes.