Understanding the usage of shortcodes

We discussed the techniques of building shortcodes in previous section. Now we need to understand the techniques of using these shortcodes in different parts of the site. Let's take a look at the different locations where we can use shortcodes:

  • Posts and pages: This is the most common use of a shortcode, where the content creator directly adds the shortcode to the post or page editor. Then, WordPress executes the shortcode and displays the result in the frontend post or page.
  • Widgets: We can use shortcodes inside WordPress widgets to provide dynamic content similar o the posts and pages. However, we have to use additional code depending on the widget we use. The WordPress Text widget allows you to add ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.