A shortcode is a small piece of code in WordPress — surrounded by square brackets — that acts as a shortcut to insert complex content or functionality into posts, pages, and widgets. Something like [contact-form] or gets replaced by actual content when the page loads.
How Shortcodes Work
Developers register shortcodes in plugin or theme code. When WordPress sees a shortcode in your content, it runs the associated function and replaces the shortcode with the generated HTML output.
Common Shortcode Examples
— displays an image gallery[contact-form-7 id="1"]— embeds a Contact Form 7 form[woocommerce_cart]— displays the WooCommerce cart[recent-posts count="5"]— shows recent posts (plugin-dependent)
Are Shortcodes Still Relevant?
With the rise of the Gutenberg block editor, shortcodes are less central than they used to be. Most modern plugins now offer dedicated blocks instead of shortcodes. But shortcodes still work and are widely used — especially with older plugins.
Creating Your Own Shortcodes
You can add custom shortcodes in your theme’s functions.php file or a code snippets plugin using the add_shortcode() function in PHP. It’s a handy skill for adding reusable bits of content without a plugin.
Related: WordPress Plugin
