Shortcodes make it easy to add extra features to your WordPress posts and pages without coding.
However, when you change themes or deactivate certain plugins, these shortcodes can become useless and show up as broken tags on your site.
These visible shortcode tags can clutter your content and confuse readers. To keep your site clean and professional, it’s important to remove any shortcodes that are no longer used.
In this guide, we’ll show you 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.
For example, you can add a beautiful responsive slider using a simple shortcode. Some page builder plugins and themes even use shortcodes to create their individual elements.
You add a shortcode in WordPress by typing or pasting a set keyword in square brackets into a post or page like this:
[some-random-shortcode]
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.
In the following sections, we’ll show you how to find and remove unused shortcodes from WordPress posts. Here’s a quick overview of all the methods we’ll share in this guide:
Ready? Let’s jump right in!
Removing Unused Shortcodes from the WordPress Back End
Our first method lets you remove unused shortcodes from your website’s posts and pages by finding and deleting them.
The first thing you need to do is install and activate the Shortcodes Finder plugin. You can learn more in our step-by-step guide on how to install a WordPress plugin.
Finding Unused Shortcodes
Upon activation, you’ll want to navigate to Tools » Shortcodes Finder. 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, and then a list of unused shortcodes is displayed. This is how it looks on our demo website:
The first 3 search results are unused shortcodes: [some-random-shortcode]
, [envira-gallery]
and [custom-twitter-feeds]
.
From here, we know that the plugins that these shortcodes rely on have been deactivated or deleted on our demo site. For example, one of the unused shortcodes comes from the Envira Gallery plugin.
Do note that the final 2 search results are false positives and are not shortcodes at all.
The \
result comes from a post that lists special characters, such as [\]^_`
. Meanwhile, the ‘simple’ result is from a post that has the words ‘simple boat’ in square brackets.
When you search your own website, you’ll want to 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.
Expert Tip: 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 the previous method 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.
You should start by installing and activating the Remove Orphan Shortcodes plugin. For more details, you can see our step-by-step guide on how to install a WordPress plugin.
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 will no longer be visible to our website visitors.
You won’t have to go find them or set anything up, as it works right out of the box.
Bonus Tip: How to Do Search and Replace in WordPress
There are many times when you’ll need to search and replace content on your WordPress site. For example, if you change your site’s domain or switch to HTTPS, you’ll need to update URLs. It’s also useful for fixing old info, typos, or broken shortcodes.
If you rebrand or need to replace a frequently used image, search and replace makes it easy to update everything quickly. This saves time and keeps your content consistent across your site.
Search & Replace Everything, made by the WPCode team, is the best tool for searching and replacing content on WordPress. You can use it for text, images, and even specific database content.
But, before starting, make sure to back up your WordPress site to avoid any issues.
For more details, you can check out our guide on how to do a search-and-replace in WordPress.
We hope this article helped you find and remove unused shortcodes from your WordPress posts or pages. You may also want to read our guides on how to remove inactive widgets and how to limit dashboard access in WordPress.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Leroy
didn’t work as the shortcode doesn’t even show up on the draft page, but sticks to the front page on website.
WPBeginner Support
If the plugin did not find the shortcode then it likely is not in your content but could be set by your theme. We would recommend checking with the support for your specific theme and they should be able to assist.
Admin
John E
Thanks for this article. It helped me fix a big problem and save a bunch of time!
Alex Standiford
I used this, but made one small change. I set the WP_Query to also look for any post type instead of just posts.
$args = array(
's' => $string,
'post_type' => 'any'
)
Simon Kelly
What a tip! I’m moving a site from Canvas to Beaver Builder and this is just what I needed to find the Woothemes shortcodes without getting into the database. Easy. Thanks!
WPBeginner Support
Glad you found it helpful
Admin
Catherine Argyros
Parse error: syntax error, unexpected ‘ob_start’ (T_STRING), expecting ‘{‘ in /home2/archtyp3/public_html/wp-content/plugins/archtypesandcircles/archtypesandcircles.com-plugin.php on line 8
I put this in my a site-specific plugin but got the above error message. please help.
i think ive got ti
i just went back in and removed all the spaces, and its WORKING! thanks again for your time and energy. I really am an absolute beginner, but with this great support Im slowly getting it…
Nehat
Hello, my website is and i used before the Shortcodes Ultimate plugin, but now i don’t use that plugin and i want to remove all shortcode from that plugin leave in posts. Can you tell me for any plugin twhich can find the unused shortcode and delete automaticaly?
yuvaraj
is anyways to find it on pages in-spite of posts
Giochi MMO
There is a way to delete a specific shortcode, maintaining the text inside?
For example: in this case [dropcap]A[/dropcap] I would like to eliminate the shortcode maintaining the “A”, or any other letter inside.
Thanks!
emeraldwave
It would be helpful if you could also add how to bulk replace the old shortcodes found to the new shortcodes used in the new theme, rather than just removing.
I think most people who migrate themes will be looking to replace like me.
Regex replace plugin is useful but does not replace shortcodes in custom post types. So we still need some kind of bulk find and replace shortcodes solution.
Paul Oyler
Does this method still work w/ WP 4.0.1? If the shortcode we wanted to find was pb_carousel group=”x” what would be the shortcodefinder to use?
Bill
If the plugin is reactivated, should the shortcodes become functional again?
WPBeginner Support
Yes.
Admin
Karen
Very helpful. But a simple Search Regex search finds the shortcode for me. That seems far less intrusive than editing the function file?
Paul
This seems like it will be a really good idea to place in the plugin deactivation action, and not allow the user to deactivate the plugin until the shortcodes have been removed or just warn the user of which posts still have these shortcodes.
raymond
Why not write a filter for the_content that runs a regex looking for all short codes in the post then checks their name against the array of shortcode hooks to see if it had any hooked functions and if not remove them from being displayed. Theyre still there but then readers don’t see them if you need to edit a lot of posts. You could put that same funcrionality in a plugin to list all posts with all unhooked shortcodes in one location so the user doesn’t have to know the exact shortcode name when needing to edit out unused shortcodes.
WPBeginner Support
Most of our beginner level users find it difficult to work with regex.
Admin
Brad Dalton
Another solution is to run a SQL query. http://www.wprecipes.com/wordpress-tip-get-rid-of-unused-shortcodes
WPBeginner Support
We do not recommend our beginner level users to run direct SQL queries on their WordPress database unless it is critical.
Admin
omid
sorry i forgot to mention that we can get list all available shortcodesby global $shortcode_tags variable.
omid
i think there might be a way.as you used the loop to find post with shortcode we can take the id of each post and with some help from wpdb class and php regex probably the goal is achivable.