Shortcodes are special instructions you put in your post or page. Like an autoembedded
URL, a shortcode tells WordPress to insert something in the current
location. But auto-embeds are limited to a relatively small set of known websites,
while shortcodes let you add a much broader range of media.
To use a shortcode, you put a predetermined code inside square brackets. For example,
the following shortcode takes all the pictures attached to a post and combines
them into a picture gallery:
An image gallery will show up here:
You’ll take a much closer look at galleries in the next section. For now, the important
thing to understand is that, when you add a shortcode to a page or post, WordPress
inserts something out of the ordinary.
Shortcodes always have the same syntax—each one consists of a bit of text wrapped
in square brackets. In fact, the instruction you learned about in the previous
section is actually a shortcode that tells WordPress to examine a web address and
embed the appropriate content.
NOTE You can type shortcodes into the visual editor (the Visual tab) or the HTML editor (the Text tab). Either
way, WordPress recognizes the code by its square brackets.
The truly neat part about shortcodes is that they’re extensible. If you’re ambitious
and you run a self-hosted WordPress site, you can create your own shortcodes
(technically, it’s all about editing the functions.php file, as described on page 500).
Even better, a clever plug-in developer can create shortcodes that let you display
additional types of content, including contact forms, documents, maps, charts, ads,
a view counter, and a PayPal donation link.
If you run a self-hosted WordPress site, you start with the shortcodes:
TIP If you run a self-hosted site, you can add the extra shortcodes that WordPress.com sites get by installing
the handy Jetpack plug-in