As you may have noticed I recently launched a new version of PenguinWP. I migrated WordPress themes in the process and unfortunately this resulted in me having to get rid of a lot of old shortcodes. As a result I discovered a few different ways to remove old WordPress shortcodes in a relatively easy fashion, so I thought I’d share what I learned.
Shortcode Removal Method #1: Search RegEx
This method is best for when you have a lot of old shortcodes that you want removed entirely from all of your posts, which are used for styling and don’t actually contain any information in them.
- Install & activate the Search RegEx WordPress Plugin
- Go to Tools > Search Regex
- Enable Regex by checking the checkbox
- To find all instances of the beginning of any shortcode and select the entirety of it, use this regular expression: [[shortcode.*]] – only replace the “shortcode” part with whichever shortcode tags you’re trying to remove.
- Then do the same for the ending tags of the same shortcode using this regular expression: [[/button.*]]
- Replace & save with nothing and those old shortcodes will be eliminated!
Shortcode Removal Method #2: Sublime Text 3
This method is best for when you have shortcodes with a similar pattern that you need to edit in bulk in a single page or post.
- Download & Install Sublime Text 3
- Copy & paste the HTML code for the post or page you want to remove the shortcodes from
- Select the beginning of the shortcode that you want to edit
- Hit Alt+F3 and this will allow you to edit all of the instances of the shortcode simultaneously
- Use your keyboard to select and edit all the instances of the shortcode that you want to edit
- Copy & paste the edited HTML code back into your post or page and save your changes
Shortcode Removal Method #3: Hide Broken Shortcodes
This is the quick & dirty method, because it doesn’t actually remove the shortcodes. Instead it just prevents them from being rendered. I wouldn’t recommend it, but it’s an option if you feel like being lazy.
- Install & activate the Hide Broken Shortcodes WordPress Plugin
- That’s it, it prevents non-functioning shortcodes from appearing in the content of a post or page
If you know of any other good methods for removing old WordPress shortcodes, please share them in the comments!