Latest Tech and Tips

How to Find and Remove Unused Shortcodes From WordPress Posts


Shortcodes are wonderful, however they are not constantly the very best method. One drawback of making use of a plugin or style that depends on shortcodes is that when you switch over a style or shut off the plugin, they will certainly leave shordcode tags in your posts which will certainly look weird to your viewers. In this post, we will certainly demonstrate how to find and remove unused shortcodes from your WordPress posts and web pages.

Are Shortcodes Bad?

No, never. Shortcodes are okay, however overusing them can be bothersome. For instance, we make use of Compact Archives plugin which supplies a shortcode and a layout tag. We have the shortcode just on our archives web page, so if we ever before shut off that plugin, after that there is simply one web page we require to remove the shortcode from.

On the various other hand, there are plugins and styles that supply shortcodes to produce typical design components like switches, tables, columns, and so on Some advertisement monitoring plugins additionally make use of shortcodes. Now if an individual has actually utilized these shortcodes in numerous posts, after that it comes to be extremely tough for the individual to remove the shortcode from all posts and web pages.

This is why we advise our customers to not depend on styles or plugins which need you to include shortcodes right into numerous posts. You need to constantly attempt to find a far better option if you can, or get in touch with the style or plugin writer. They may inform you a far better method to obtain the exact same capability without making use of a lot of shortcodes in posts or web pages.

For those still asking yourself, if you have a non-active shortcode on your website, after that it will certainly appear like this in the middile of your web content:


In order to remove unused shortcodes from your posts and web pages, you require to initially find them.

Find All Posts Containing a Particular Shortcode

We will certainly attempt the easiest strategy to find the shortcode inside blog post web content. Simply duplicate and paste the complying with code in a site-specific plugin or your style’s functions.php data:

feature wpb_find_shortcode($ atts, $material= null) {
essence( shortcode_atts( selection(.
' find' => >",.
), $atts) );.

$ string = $atts['find'];.

$ args = selection(.
's' => > $string,.

$ the_query = brand-new WP _Query( $args );.

if ($ the_query->> have_posts()) {
resemble '<< ul>>';.
while ($ the_query->> have_posts()) {
$ the_query->> the_post();?>>.
<< li><> < a href ="<?php the_permalink() ?>"><>