Understanding WordPress Shortcodes – Beginners Guide

shortcodeShortcodes were introduced in WordPress 2.5 and are used for adding macros to a page or post.

There are several built in shortcodes like the Gallery shortcode that come with WordPress, but you will encounter Shortcodes most often after you install plugins.

Shortcodes are designated using square brackets. So to insert a picture Gallery into a post,you enter the following into the post:

Most shortcodes consist of a single tag, but some shortcodes require a closing tag. The caption shortcode is:

caption-shortcode

Notice the closing tag uses the backslash just as in HTML tags

The best way of understanding shortcodes is to see it in action.

So we are going to look at the contact form shortcode.

Here are the instructions for the FS contact form:

contact-form-shortcode

This is how I add it to a page or post

contact-form-shortcode-use

 

This is what the page visitor sees

contact-form

You can see that the shortcode has been replaced by the actual contact form.

Common Questions and Answers

Q- Can I create my own shortcodes?

A- Yes but you need a knowledge of the WordPress code and php.

Q- Does the visitor or search engine see the shortcode.

A- No they see the contents of the shortcode.

Summary

Shortcodes are macros that can be used for adding various objects like contact forms, polls etc to a web page.

WordPress comes with some shortcodes but in the main, you will encounter them when using plugins.

With a little basic programming knowledge you can easily create your own shortcodes.

Related Tutorials and resources: