Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Find and Remove Unused Shortcodes in WordPress

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

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.

How to Find and Remove Unused Shortcodes From WordPress Posts

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 or a survey form 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.

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.

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 will be taken to the Tools » Shortcodes Finder page. Once there, you should click on the ‘Find unused Shortcodes’ tab.

The Shortcode Finder Plugin Allows You to Find Unused Shortcodes in Posts and Pages

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:

Shortcode Finder Will Display a List of Unused Shortcodes

The first three search results are unused shortcodes: [some-random-shortcode], [envira-gallery] and [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.

The Shortcode Finder Plugin May Include False Positives in the Search Results

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.

Click the Edit Content Icon to Remove the Shortcode

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.

You Need to Edit Each Post to Remove the Unused Shortcodes

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.

You should start by installing and activating the Remove Orphan Shortcodes plugin. For more details, 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.

Unused Shortcode Is Visible in Your Posts and Pages

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.

The Remove Orphan Shortcode Plugin Hides Unused Shortcode

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.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

24 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Leroy says

    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 says

      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

  3. Alex Standiford says

    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'
    )

  4. Simon Kelly says

    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!

  5. Catherine Argyros says

    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 says

      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… :)

  6. Nehat says

    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?

  7. Giochi MMO says

    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!

  8. emeraldwave says

    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.

  9. Paul Oyler says

    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?

  10. Karen says

    Very helpful. But a simple Search Regex search finds the shortcode for me. That seems far less intrusive than editing the function file?

  11. Paul says

    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.

  12. raymond says

    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.

  13. omid says

    sorry i forgot to mention that we can get list all available shortcodesby global $shortcode_tags variable.

  14. omid says

    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.

Leave a Reply to omid Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.