Shortcode Tutorial – Default WordPress Shortcodes

Share this Article

WordPress shortcodes are square bracket strings ([ ]) that magically transform into something fascinating on the frontend.

WordPress comes with 6 default shortcodes.

  • audio
  • caption
  • embed
  • gallery
  • playlist
  • video

In above list of default shortcodes, some of they are self-closed shortcodes. Some are enclosed shortcodes.

[ audio] Shortcode

The Audio feature allows you to embed audio files and play them back using a simple Shortcode.

Syntax

[audio]

Example

[audio src="audio-source.mp3"]

[audio mp3="source.mp3" ogg="source.ogg" wav="source.wav"]

[ caption] Shortcode

The Caption shortcode allows to wrap captions around content using a simple shortcode. This is used with individual images

Syntax

[caption] <image> Caption [/caption]

Example

[caption id="attachment_6" align="alignright" width="300"]

   <img src="http://localhost/wp-content/uploads/2021/12/sample.jpg" /> Sample Text

[/caption]

[ embed] Shortcode

The Embed shortcode allows to wrap embedded items using a simple shortcode to set of a maximum width and height.

Syntax

[embed] ... [/embed]

Example

[embed width="700" height="500"] ... [/embed]

[ gallery] Shortcode

The Gallery shortcode allows to add one or more image galleries to posts and pages using a simple shortcode. By using this we can create galleries of images.

Syntax

[gallery]

Example

[gallery ids="729,732,737,740"]

729, 732, … are image IDs. It will create a image gallery.

[ video] Shortcode

The Video shortcode allows to embed video files and play them back using a simple shortcode.

Syntax

[video]

Example

[video mp4="source.mp4" ogv="source.ogv" webm="source.webm"]

So, here we have seen the detailed concept of default wordpress shortcodes. In coming tutorials we will see how to create our own shortcode and how to use it in wordpress.

Was this post helpful?

Learn Web Development Courses Risk Free @ $5 only.
Web Development Courses @ $5