Find posts containing a shortcode

A little helper to find posts which contain a specific shortcode. If you switch themes and the shortcodes are not transfered to a plugin your site’s content will break. If you have many posts you can use this helping snippet to list all posts containing your specified shortcode so you can remove or edit the broken posts and pages.

/**
 * Snippet Name: Find posts containing a shortcode
 * Snippet URL: https://www.wpcustoms.net/snippets/find-posts-containing-shortcode/
 */
  // usage in postpage: [shortcodefinder find='myshortcode']
function wpc_find_shortcode($atts, $content=null) { 
ob_start();
extract( shortcode_atts( array(
		'find' => '',
	), $atts ) );

$string = $atts['find'];

$args = array(
	's' => $string,
	);

$the_query = new WP_Query( $args );

if ( $the_query->have_posts() ) {
        echo '


Add to bookmarks |
Share on Twitter
|
added:
| credits
| help

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x