WordPress shortcodes are small bracketed snippets that add dynamic content to a page, post or widget area without asking you to write lots of code.
If you have ever pasted something like [contact-form], or into WordPress, you have used one. This guide explains what are shortcodes in WordPress, where to put them, and which ones are still useful.
You will also find practical wordpress shortcode examples for galleries, buttons, forms, reusable notices and simple custom features.
What are shortcodes in WordPress?
A shortcode is a WordPress-specific shortcut, usually written inside square brackets. WordPress shortcodes are processed before the page is shown to visitors, then replaced with the output that the shortcode is designed to create.
For example, can display a gallery, while a form plugin might give you something like [contact-form-7 id='123']. The shortcode itself is not the final design; it is an instruction that WordPress or a plugin understands.
The official WordPress documentation describes the Shortcode API as a way for developers to add forms, galleries and other generated content to posts and pages. You can read the technical reference in the WordPress Shortcode API handbook.
WordPress shortcodes are not the same as blocks, patterns or HTML. Blocks are visual editing elements in the block editor, while shortcodes are compact text commands that often come from WordPress core, a plugin or a theme.
How wordpress shortcodes work
Most shortcodes have a name, and many accept attributes. Attributes are extra settings that change the output, such as an ID, size, colour, category or layout.
In that example, gallery is the shortcode name. The other pieces tell WordPress which images to use, how many columns to show and which image size to display.
WordPress shortcodes can be self-closing or enclosing. A self-closing shortcode stands alone, such as . An enclosing shortcode wraps around content, such as [notice]Free delivery this week[/notice].
The important thing for site owners is simple: if the plugin or theme that created a shortcode is removed, the shortcode may stop working and appear as plain text. Before deleting a plugin, check whether your pages rely on its shortcodes.
15 useful wordpress shortcode examples
The best wordpress shortcode examples are practical, repeatable and easy to understand. Some of the examples below are built into WordPress, while others are common patterns supplied by form, ecommerce, membership or page-building plugins.

| Example | What it can do | Notes |
|---|---|---|
| Shows a selected image gallery. | Built into WordPress, though many sites now use gallery blocks instead. |
| Embeds an audio player. | Useful for podcasts, samples or interviews. |
| Embeds a video player. | Often better to host large videos on a video platform. |
| Displays a collection of audio or video files. | A core shortcode for media-heavy sites. |
Image caption | Adds a caption around content. | Mostly handled visually by modern image blocks. |
https://example.com/video | Wraps embedded content. | WordPress also supports many automatic embeds. |
[contact_form id='123'] | Places a form on a page. | The exact name depends on your form plugin. |
[newsletter_signup] | Adds an email sign-up form. | Check that consent wording is clear. |
[button url='/contact/']Get a quote[/button] | Creates a styled call-to-action button. | Often supplied by themes or custom code. |
[pricing_table id='basic'] | Displays pricing cards or packages. | Useful if prices are managed in one place. |
[testimonials count='3'] | Shows selected reviews or testimonials. | Keep testimonials genuine and current. |
[latest_posts count='5'] | Lists recent posts. | A query loop block may be better on modern sites. |
[opening_hours] | Shows business opening times. | Helpful if hours are reused across several pages. |
[map address='York'] | Embeds a map or location panel. | Map plugins may require an API key. |
[members_only]Private note[/members_only] | Restricts content to logged-in members. | Use a reputable membership plugin for access control. |
WordPress shortcodes from plugins can be extremely convenient, but do not assume every example will work on your site. The shortcode has to be registered by WordPress core, your theme, a plugin or your own code.
If you are browsing designs for inspiration, our collection of real WordPress website examples can help you decide where a shortcode might be useful and where a normal block would be cleaner.
How to add wordpress shortcodes to a page
The safest way to add WordPress shortcodes in the block editor is to use the Shortcode block. WordPress says the block can be added from the block inserter, or by typing /shortcode and pressing enter; its user documentation is on the official Shortcode block page.
- Open the page or post you want to edit.
- Click the block inserter, or type
/shortcode. - Choose the Shortcode block.
- Paste the shortcode exactly as provided.
- Preview the page before publishing.
You can also paste a shortcode into some classic editor areas, text widgets or plugin settings, depending on how the site is built. If it appears as plain text on the front end, that usually means the shortcode is not registered there, has been typed incorrectly, or belongs to a plugin that is inactive.
For layout features such as page numbers, use the most maintainable option rather than adding shortcodes everywhere. Our guide to adding pagination in WordPress explains where native settings, theme support or plugins may be a better fit.
Creating your own wordpress shortcodes
You can create WordPress shortcodes with PHP, normally in a small custom plugin or a child theme. A custom plugin is often cleaner because the shortcode keeps working if you change theme.
Here is a deliberately simple example that outputs a reusable phone number. It is not meant to replace a full plugin, but it shows the basic idea.
<?php
function sas_phone_shortcode() {
return '<a href="tel:+441234567890">01234 567890</a>';
}
add_shortcode( 'business_phone', 'sas_phone_shortcode' );
Once added safely, you could place [business_phone] on any page that needs the same number. If the number changes, you update the code once instead of editing several pages.
For anything beyond a basic internal site feature, follow the WordPress Plugin Handbook guidance on shortcodes. It recommends returning output rather than printing it directly, prefixing names to avoid clashes, and sanitising input before using it.
WordPress shortcodes that accept attributes need extra care. User-entered values should be checked, cleaned and escaped so the shortcode cannot break your layout or introduce a security problem.
Best practices for wordpress shortcodes
Used well, WordPress shortcodes make a site easier to manage. Used carelessly, they create hidden dependencies that are hard to tidy up later.
- Keep names clear:
[business_phone]is easier to understand than[bp1]. - Document each shortcode: keep a note of what it does, where it came from and which attributes are allowed.
- Use blocks where they fit: blocks are usually easier for non-technical editors to see and adjust.
- Avoid locking key content inside one plugin: if a plugin is abandoned, replacing dozens of shortcodes can be painful.
- Preview before publishing: a missing bracket or wrong ID can stop the output appearing.
- Test after updates: check important pages after WordPress, plugin or theme updates.
If your shortcode adds a visual element, make sure it still works on mobile screens. A pricing table or gallery that looks tidy on a desktop can become awkward on a phone.
Good hosting also matters because heavy forms, galleries and membership shortcodes can add database queries or external requests. If you are reviewing the foundations of your site, start with our WordPress hosting guides.
Troubleshooting wordpress shortcodes
When WordPress shortcodes fail, the first clue is usually what you see on the page. If the raw shortcode appears, WordPress has not processed it. If nothing appears, the shortcode may be processed but returning empty output.
Check spelling and brackets
Shortcodes are unforgiving. Compare the shortcode with the plugin documentation, including underscores, hyphens, quote marks and closing tags.
Check the plugin or theme
If a shortcode came from a plugin, confirm that the plugin is installed and active. If it came from a theme, it may disappear when you switch to a different theme.
Check where you placed it
Some shortcodes work in post content but not in every template, widget area or builder field. The Shortcode block is usually the best first test in the block editor.
Check caching
A cache can make an old version of a page appear even after you fix the shortcode. Clear your site cache and, if relevant, your hosting or CDN cache.
For developers, WordPress provides functions such as add_shortcode(), shortcode_atts() and do_shortcode(). The official add_shortcode function reference explains the callback structure in more detail.
When not to use shortcodes
Shortcodes are useful, but they are not always the best answer. If an editor needs to see and change a layout visually, a block is usually friendlier than a bracketed command.
Avoid using shortcodes for main page structure if your theme or editor already provides proper blocks. Overusing them can make content harder to move, search, translate and maintain.
Also be cautious with shortcodes that control private content, payments or personal data. For those jobs, use a well-maintained plugin with proper permissions, logging and security support rather than a quick custom snippet.
For small reusable details, such as a phone number, opening-hours notice or call-to-action, a shortcode can still be neat. The test is whether it makes future editing easier, not whether it feels clever.
WordPress Shortcodes FAQs
What are shortcodes in WordPress used for?
They are used to insert dynamic content with a small bracketed command. Common uses include galleries, contact forms, audio players, pricing tables and reusable business details. The exact output depends on WordPress core, your theme, your plugins or your custom code.
Are wordpress shortcodes still useful with the block editor?
Yes, wordpress shortcodes are still useful, especially when a plugin supplies a feature as a shortcode. However, blocks are often easier for visual layouts because you can see and adjust them directly in the editor.
Why is my shortcode showing as plain text?
This usually means WordPress does not recognise it in that location. Check that the shortcode is typed correctly, the plugin that provides it is active, and you have placed it in a Shortcode block or another supported area.
Can I make my own wordpress shortcode examples for a business site?
Yes, you can create simple custom shortcodes for reusable items such as a phone number, opening-hours notice or call-to-action. For anything involving forms, accounts, payments or private data, use a reputable plugin or ask a developer to build it securely.
Do wordpress shortcodes slow down a website?
A shortcode itself is not automatically slow. Performance depends on what it loads, such as large galleries, maps, external scripts or complex database queries. Test important pages after adding new shortcodes, especially on mobile.
Final word
WordPress shortcodes are simple on the surface, but powerful when used with care. They can add galleries, forms, media, notices and reusable business details without forcing every editor to touch code.
Use them where they genuinely save time, document the important ones, and choose blocks when visual editing matters more. That balance keeps your WordPress site flexible, tidy and easier to maintain.



