Themewaves
How-To

How to Add and Manage WordPress Shortcodes

Find, add, edit, and troubleshoot WordPress shortcodes with confidence.

How to Add and Manage WordPress Shortcodes

Understanding shortcodes in WordPress

What is a shortcode in WordPress? It is a short code in square brackets that tells WordPress to show a feature or content. A plugin might use one to display a form, gallery, or event list. The code saves you from building that feature by hand.

WordPress, a theme, or a plugin can register a shortcode. It only works while the tool that provides it is active. If you remove that plugin, its shortcode may show as plain text or stop showing content.

Some shortcodes accept attributes. These are settings written inside the brackets, such as an item ID or image size. Use only settings listed by the plugin maker. Shortcodes are useful, but a dedicated block may be easier to manage.

  • Use a shortcode when a feature offers one.
  • Note which theme or plugin provides the code.
  • Test the result before you publish changes.

Keep the page lean. Each added plugin can affect site speed and upkeep. Avoid adding several tools to do the same job.

How to find and copy a shortcode

First, open the plugin or theme that provides the feature. Check its settings, help panel, or own support pages. Form tools often list a code beside each form. Gallery tools may show one after you build a gallery.

Open the item you want to show, then look for a label such as “Shortcode” or “Embed.” Copy the whole code, including both square brackets and any settings. Do not copy nearby punctuation or add spaces inside the brackets.

Do not guess the shortcode name. Similar tools can use different codes. If you cannot find one, check the maker’s help pages or settings before trying another method.

  1. Open the plugin or theme settings.
  2. Select the form, gallery, or other item.
  3. Copy the shortcode shown for that item.
  4. Keep a copy until you confirm it works.

A form plugin might show a code like [contact-form id="12"]. Your code and settings will depend on that plugin. Treat this as an example, not a code to copy.

Blank cards beside a vivid red box on a clean white and graphite surface
Finding a shortcode

How to add a shortcode to a WordPress page

To add a shortcode to a WordPress page, open the page in the Block Editor. Select the spot where the feature should appear, then click the plus button. Search for “Shortcode,” add that block, and paste in your code.

This is the simplest way to insert a shortcode in WordPress. The editor may show the code rather than the finished feature. Preview the page or view it on your site to check the result.

With the Classic Editor, open the page and choose the Visual tab. Paste the code where you want the feature to appear. You can also use the Text tab, but avoid adding extra HTML around the code.

Use the dedicated Shortcode block when possible. It is easy to find and move later. If the feature must sit inside another block, follow the plugin maker’s steps.

  • Place the shortcode close to related page content.
  • Preview on desktop and mobile.
  • Check that the feature appears only once.

This covers how to use a shortcode in a WordPress page without changing theme files. Choose a plugin’s own block instead when it offers one and meets your needs.

Blank page layout with a vivid red panel and graphite shapes on white
Adding a shortcode to a page

Inserting shortcodes in posts

To insert a shortcode in a WordPress post, use the same steps as for a page. In the Block Editor, add a Shortcode block and paste in the code. Put it near the text that explains the form, gallery, or other feature.

In the Classic Editor, paste the code at the right point in the post. A separate line can make it easier to spot while editing. Preview the post before you publish it.

Some plugins offer both a block and a shortcode. A block may make its settings easier to change. A shortcode can suit an older post or a simple embed. Pick one method for each feature to avoid showing it twice.

Check the feature beside nearby content. A wide gallery may not fit a narrow column. A form may need a short note that tells readers what to do. Small checks can prevent a confusing layout.

If you need to change the feature later, save the post and check it again. Do not assume the editor preview matches the live page. Some plugins only render the final result on the site.

Blank stacked sheets beside a vivid red notebook and graphite objects
Adding a shortcode to a post

How to edit an existing shortcode

To edit a shortcode in WordPress, open the page or post that holds it. In the Block Editor, select its Shortcode block and change the code or settings. In the Classic Editor, find the code and update only the part you need.

Keep both square brackets in place. Check each quote, equal sign, and space against the plugin’s example. A missing bracket or quote can stop the feature from working.

For instance, a gallery may let you set the number of columns. Change that value only if the plugin supports it. Save the old code before you test a larger change.

  • Change one setting at a time.
  • Keep the old code until the new one works.
  • Preview the page after each change.

If a plugin update changes its shortcode, check the maker’s notes. Do not replace every code on your site until you know which pages use it. Make a backup before broad edits.

Blank white cards divided by a vivid red shape with graphite details
Editing shortcode settings

Using shortcodes in PHP files

Developers can run a shortcode from a PHP template with WordPress’s do_shortcode function. For example, use echo do_shortcode('[contact-form id="12"]'); where the feature should appear. Replace the sample code with the shortcode from your own plugin.

This answers how to add a shortcode to WordPress in PHP. Add the call to a suitable theme template or a child theme. Avoid editing a parent theme, since an update can erase your changes.

Use PHP only when the feature must appear in a theme file. For normal page content, the Shortcode block is safer and easier to change. Test template edits on a staging site before using them on a live site.

Some plugins may not register their shortcodes at the point your template runs. If nothing appears, check that the plugin is active and that the code runs after WordPress loads it. Ask the plugin maker for its recommended template method.

Troubleshooting common shortcode issues

If the code appears as text, check that the shortcode is spelled right and uses square brackets. Confirm that the plugin or theme that provides it is active. Also check that you added it to a block or editor area that supports shortcodes.

If the feature is missing, verify its ID and settings. Copy the code again from the plugin rather than typing it from memory. Preview the page after each fix so you can spot what changed.

A broken layout may come from the shortcode’s settings or from the theme. Test the same code on a draft page with a simple layout. If it works there, add it back to the original page and check nearby blocks.

  • Check brackets, quotes, spelling, and attributes.
  • Make sure the source plugin is active.
  • Try one shortcode on a plain draft page.
  • Use a block instead if the plugin provides one.

For better speed and easier upkeep, use only the shortcodes you need. Remove unused plugins only after checking whether their shortcodes appear on live pages. Plan a replacement first, or old codes may show to visitors.

Step-by-step

  1. 01
    Find the shortcode

    Open the plugin or theme that provides the feature. Copy the code shown for the item you want to display.

  2. 02
    Add a Shortcode block

    Edit the page or post in the Block Editor. Add a Shortcode block where the feature should appear.

  3. 03
    Paste the code

    Paste the full shortcode into the block, including its square brackets and settings. Do not add extra punctuation.

  4. 04
    Preview and test

    Preview the page or post on desktop and mobile. Check that the feature works and appears only once.

Frequently asked questions

What is a shortcode in WordPress?
A shortcode is a small code in square brackets that tells WordPress to display content or a feature. A plugin, theme, or WordPress tool must provide it.
How do I add a shortcode to a WordPress page?
Open the page in the Block Editor, add a Shortcode block, and paste in the full code. Preview the page to confirm the feature appears.
Can I add a shortcode with the Classic Editor?
Yes. Paste the code where you want the feature in the Visual or Text tab. Keep the brackets and settings intact, then preview the page.
How do I edit a shortcode in WordPress?
Open the page or post and edit the Shortcode block or code in the Classic Editor. Change one supported setting at a time and test the result.
How do I use a shortcode in a PHP template?
A developer can call WordPress’s do_shortcode function in a theme template. Use a child theme and test changes before adding them to a live site.
Why does my WordPress shortcode show as plain text?
Check the spelling, square brackets, and plugin status. The editor area may not support shortcodes, or the plugin that registered the code may be inactive.
Share XFacebookWhatsApp

Related reading

About cookies on this site

Essential cookies keep pages loading and the enquiry form working. Anything beyond that is optional and we only set it if you say yes. Details live in our Cookie Policy.