Do you need to remove unused shortcodes from posts on your WordPress website?
Shortcodes allow you to add extra functionality to WordPress posts and pages without writing any code. But if you switch themes or deactivate a plugin, then the shortcodes will stop working and the tags will become visible to your readers.
In this article, we will show how to find and remove unused shortcodes from your WordPress posts and pages.
Are Unused Shortcodes a Problem in WordPress?
Shortcodes are an easy way to add dynamic content to your WordPress website. While many WordPress plugins and themes now use blocks instead of shortcodes, many still use shortcodes to add specialized content like contact forms, image galleries, sliders, and more.
You add a shortcode in WordPress by typing or pasting a set keyword in square brackets into a post or page like this:
But there’s a problem when you deactivate the plugin or switch away from the theme that the shortcode relies on. When that happens, the shortcode becomes inactive and your readers will see the actual shortcode tag in square brackets when they visit your website.
Let’s take a look at how to find and remove unused shortcodes from WordPress posts. We’ll cover two methods, one that physically removes the shortcode tags from your posts and pages, and the other that simply hides them from your website visitors.
Removing Unused Shortcodes from the WordPress Backend
Our first method lets you clean up unused shortcodes by finding and deleting them from the posts and pages on your website.
Finding Unused Shortcodes
Upon activation, you will be taken to the Tools » Shortcodes Finder page. Once there, you should click on the ‘Find unused Shortcodes’ tab.
By default, the plugin will only search published content. If you also want to search drafts and scheduled posts, then you should check the ‘Include not published contents’ box.
Now you can click either the ‘Posts’ or ‘Pages’ button to search for unused shortcodes in your content. For this tutorial, we’ll click on ‘Posts.’
A progress bar is displayed while the plugin searches your posts, then a list of unused shortcodes is displayed. This is how it looks on our demo website:
The first three search results are unused shortcodes:
[custom-twitter-feeds]. The plugins that these shortcodes rely on have been deactivated or deleted on our demo site.
The final two search results are false positives and are not shortcodes at all. The
\ result comes from a post that lists special characters such as
[\]^_`. And the ‘simple’ result is from a post that has the words ‘simple boat’ in square brackets.
When you search your own website, make sure that you only remove true unused shortcodes and not false positives.
Removing Unused Shortcodes
The best and safest way to remove unused shortcodes from your posts is to manually edit each post or page containing the shortcode. This will allow you to check for false positives and decide the best way to edit the post.
That’s because besides deleting the shortcode, you might also have to edit other material in the post. The surrounding paragraphs may refer to information that was previously displayed by the shortcode and is no longer visible.
When you click on a blue shortcode line, you will see a list of posts that contain the shortcode. To edit a post, you need to click its ‘Edit Content’ icon.
Hint: You might find it easier to edit each post in a different browser tab. Simply right-click each icon and choose ‘Open Link in New Tab’ from the menu, or you could also Ctrl-Click the icon (Windows) or Command-Click it (Mac).
When the WordPress editor opens, you can delete the shortcode from the post.
In the example below, the paragraph before the shortcode should also be deleted or edited because it refers to a photo gallery that is no longer visible.
Once you’ve finished removing unused shortcodes from all of your posts, you should repeat the process by clicking the ‘Pages’ button to clean up your WordPress pages as well.
Hiding Unused Shortcodes on the WordPress Front-End
This second method doesn’t actually delete the unused shortcode tags from your posts and pages like Method 1, but simply hides them from your website visitors.
This is faster and can be helpful if you want to hide the shortcodes before you’re able to remove them all. You may also want to simply hide them in case you reinstall or reactivate the plugin or theme that put them there.
On activation, the plugin starts to work automatically and removes unused shortcodes from being displayed on your website’s front end. This offers a better user experience.
Here’s an example from our test website. Before the plugin was installed, an unused shortcode could be seen on our site’s front end.
After the Remove Orphan Shortcodes plugin is installed and activated, the shortcode is no longer visible to our website visitors.
You won’t have to go find them or set anything up. It works right out of the box.
We hope this article helped you find and remove unused shortcodes from your WordPress posts or pages. You may also want to learn how to increase your blog traffic, or check out our list of common WordPress errors and how to fix them.