If you’ve been managing a WordPress site, you might have experimented with various plugins and themes that use shortcodes to enhance your content. Over time, if you stop using these tools, their shortcodes can remain and clutter your site, making it look messy.
Luckily, cleaning up these unused shortcodes isn’t tricky. Let’s quickly go through how to tidy up these leftovers and keep your site looking its best.
Contents
Why Remove Unused Shortcodes?
If you deactivate a plugin or theme that introduced a shortcode, WordPress doesn’t automatically remove it. As a result, the shortcode appears on your site as plain text, which doesn’t look good and could confuse your visitors.
Removing them is a good way to clean up your content and improve your website’s overall appearance.
Typical Cases of Unused Shortcodes
- Deactivated/Deleted Plugins – Shortcodes from previously active plugins remain in your content after deactivation or deletion.
- Switched Themes: Short codes specific to your old theme may appear in plain text after switching to a new theme.
- Unused Custom Shortcodes – Custom shortcodes that are no longer relevant may still exist in your posts or pages.
- Misconfigured Shortcodes – Shortcodes misused or tied to broken plugins can show as raw text on the front end.
- Removed Features – Features like galleries or sliders, when removed, may leave their associated shortcodes behind.
- Imported Content – Content imported from another site may contain shortcodes incompatible with your current plugins or theme setup.
3 Ways to Find and Remove Unnecessary Shortcodes
- Use a Plugin
- Delete from Database
- Edit
functions.php
Note: Before making any changes, it’s wise to back up your website. You can quickly restore anything to its previous state if anything goes wrong. WP Staging offers a simple solution for automatic backups. For further assistance, refer to the backup and restore guide.
1. Use a Plugin
A plugin is the easiest way to find and remove unused shortcodes in WordPress. Here’s how you can do it:
Search the WordPress plugin directory for a shortcode cleanup plugin like “Shortcode Finder.” Once found, install and activate the plugin.
After activating the plugin, navigate to the plugin’s dashboard and click on the “Find Unused Shortcodes” tab.
Next, click the “Post” or “Page” button to find unused shortcodes within your content.
After completing the search, you will see a list of unused shortcodes. Click on any shortcode to access it, then click the edit icon to go to the page where the unused shortcode is located.
Next, locate the unused shortcode on the page and delete it.
This method is quick, requires no coding, and ensures your site stays clean without searching for shortcodes manually.
2. Delete from Database
If you prefer a more hands-on approach, you can delete unused shortcodes directly from the WordPress database. This method involves accessing your database through tools like phpMyAdmin. Here’s how to do it:
Log in to your hosting account and navigate to phpMyAdmin, typically found in your hosting control panel (such as cPanel).
In phpMyAdmin, select the database corresponding to your WordPress site, then click on the “SQL” tab.
Note: To use this method, you must know the shortcode name. If unsure, you may delete it directly from the database. It’s also advisable to back up your database beforehand to restore any files.
Type the code below, replacing [shortcode]
with the actual name of the shortcode you want to remove. Then, click the “Go” button to execute the query, permanently deleting the shortcode.
UPDATE wp_post SET post_content = replace(post_content, ‘[shortcode]’, ” ) ;
Sometimes, new shortcodes from themes or plugins may offer the same functionality as old shortcodes. In such cases, you can replace the old shortcodes with the new ones without removing them.
Just add the following code and type the old shortcode names in the box [old shortcode]
and the new shortcode names in the box [new shortcode]
.
UPDATE wp_posts SET ‘post_content’ = REPLACE (‘post_content’,'[ old shortcode ]’, ‘[ new shortcode ]’);
This method is more technical and should be used only if you’re comfortable working with databases. If not, it’s better to use a plugin or manually remove it through the WordPress dashboard.
3. Edit functions.php
You can manually remove unused shortcodes by adding code to your theme’s functions.php
file. This method helps clean up shortcodes across your site without using a plugin. Here’s how:
In your WordPress dashboard, go to Appearance > Theme Editor. On the right-hand side, find and select the functions.php
file of your active theme.
Scroll down to the bottom of the functions.php
file, and add the following code to unregister the unused shortcode:
add_shortcode( ‘shortcode’, ‘__return_false’ );
Type the original shortcode name in place of 'shortcode'
to replace it. Then, click the “Update File” button to save your changes.
These changes are theme-specific. If you change your theme, you’ll need to reapply this method to the new theme’s functions.php
file.
Conclusion
Unused shortcodes can clutter your WordPress site and make it look unprofessional. Regularly checking for and removing them can keep your content clean and ensure a smooth experience for your visitors.
Whether you do it manually or use a plugin, the steps above will help you quickly find and remove unwanted shortcodes. Happy cleaning!