What shortcodes are and how they work

Table of contents

  1. Intro
  2. Simple shortcodes
  3. Shortcodes with content 
  4. Nested shortcodes

Intro

Shortcode is a specific WordPress code allowing you to create various elements on the site easily. With the help of shortcodes, you can publish videos, photo galleries, forms, etc. on the site using only one line of code. Shortcodes are written in square brackets.

Shortcodes can be used in WordPress editor, in text widgets, in theme files, and other places.

Simple shortcodes

This is how simple shortcode looks like:

[shortcode]

Shortcodes may have settings, for example:

[gallery_shortcode ids="1, 2, 3"]

Shortcodes with content 

Shortcode may have closing tag, with the help of which shortcode may contain some text. For example:

[button] Click me [/button]

Nested shortcodes

A shortcode may contain other shortcodes. However, identical shortcodes cannot be nested into each other. Example of nested shortcodes:

[box] Hello, [username] [/box]

WordPress provides a set of standard shortcodes: audiocaptionembedgalleryvideo, and playlist. Learn more about shortcodes from WordPress codex.

Shortcodes Ultimate adds 50 new shortcodes which you can use.

Note: shortcodes specified in this article are only examples and will not work on your site.

Helpful?
🤝 Thank you!