ShortCode plugins can help create a beautiful site but can be a big headache to remove if you don’t need them. Here is how you can easily remove ShortCode Plugin from your WordPress Sites.
ShortCodes are an effective way to add functionality to your WordPress site. There are many plugins available in the WordPress plugin repository which allows doing different things.
These plugins come in a sticky product category as once you start using them, they will be hard to remove. If you try to remove, you need to go and update each of your post or page where you have used those shortcodes. That is one of the reasons many people recommend you to not use Shortcode plugins.
When you start a blog, you might add many plugins but with time you will gain understanding of which one is working fine. I have been in this situation many times. Sometimes plugin author just abandons the plugin, and you need to replace it with another one. To do that you need to remove the old plugin and you end up doing too much manual work.
How To Remove ShortCode Plugin From WordPress
WordPress is a preferred CMS for many because it is easy to manage it. You can uninstall the shortcode plugin like any other WordPress plugin, the problem comes with the usage of shortcodes which needs to be replaced appropriately.
There can be multiple scenarios based on how you want to handle the shortcodes in your posts.
– You do not care about those shortcodes and want to just remove them from your posts.
– You do want to remove the shortcodes but would like the content (used by the shortcodes) to display in the posts.
– If you have installed a new shortcode plugin, you would want to replace the old shortcode with the new one.
So let’s take a look at the scenario and see how we can handle them.
How To Remove the ShortCodes From Posts
It’s easy if you only have few posts on your blog but if you have thousands of posts, it will become tough to replace those shortcodes.
Here is how you can handle it easily in 3 steps.
Step 1: Create a list of Shortcodes used by that plugin on your site.
The first thing you would need is a list of shortcodes which you have used from that plugin. If you are not sure about the used shortcodes than create a list of all shortcodes available from that plugin.
The idea is to remove the shortcode plugin but keep all the shortcodes alive and generate no output for those shortcodes.
Step 2: Go ahead and uninstall the ShortCode Plugin from WordPress
Now you can go ahead and uninstall the plugin from WordPress admin dashboard. This will remove the plugin and all of your posts will start showing the shortcodes as a text. They will be shown as below in your posts:
Step 3: Use the below mention code to replace the shortcodes with spaces
One way to remove the shortcodes is by going through each post and page and editing them. Another way we can create shortcodes again and make sure it outputs nothing.
This way you can just add a small function in your functions.php file and the shortcode will go away from all your post and pages.
You can just add more lines of “add_shortcodes” and change the shortcode name if you are looking to replace more than 2 shortcodes.
Once you update your functions.php, all of your shortcode text will start generating no output and will not be seen in your post and pages.
Remove ShortCodes But Keep The Content
There are enclosing shortcodes which take a content as an input and generate formatted output. They will look like the format mentioned below:
If you want to remove those shortcodes but would like to keep displaying the content, you can use the below mention code in your functions.php.
Rest of the steps are same, just uninstall your shortcode plugin like any other plugin and use the above mention code for generating a plain content.
Replace Shortcode with another Shortcode
This is going to be little tricky as you need to understand shortcode structure and convert it into a new format. WordPress comes with a function called do_shortcode, we can use that to execute shortcodes.
Let’s take an example to understand this process –
Suppose you have below shortcode which you want to remove from your blog
and this is the new shortcode which you want to use going forward on your blog
In a manual way, you need to go into each post and convert the shortcode manually. But it can also be done with a small function which you can add in your functions.php to get it converted automatically.
The first thing which you need to check is what arguments old and new shortcodesโ are taking. You need to match the old arguments with new arguments and use it to convert the shortcode on the fly with the help of below function.
do_shortcode function takes a string as an input which is the content in which it will process all the shortcodes. We need to create a new shortcode and format it in the same way as you would replace it in your post to pass it to the function.
If they have a different number of arguments then check on how many you can match. if you can’t match some of the old arguments, just drop them and see if your new output is good.
Conclusion
This way you can replace all instances of your old shortcode with a small function in your functions.php file.
I hope these methods will help you in removing shortcodes from WordPress and saves an effort of looking into each post to manually update those.
Thanks For Sharing This Sanjeev, It helped me convert my old shortcode into a new one.
On the other note, your bottom sharing buttons are looking good can you tell me how to do this?
Hi Praveen,
Glad you like the blog. For the bottom Social sharing buttons I am using Social Warfare WordPress Plugin. Check it out, it does a lot of good things for your social-media management.
– Sanjeev