How to Check if Shortcode already Exist in WordPress

Luckily, In WordPress 3.6.0, they have introduced a new function that will allow us to check the existence of shortcodes.

By using shortcode_exists($shortcode_tag), A function that can easily check if any shortcode already available in WordPress or not.

Eg: Let’s check for the default [gallery] shortcode that comes with WordPress.

	if(shortcode_exists('gallery'))
	{
		echo "shortcode already exist";	
	}
	else 
	{
		echo "shortcode not found";
	}

You can also check the existence of custom build shortcodes as well. All you need to do is just pass the shortcode tag in the function as parameter. Something like given below

        shortcode_exists( 'my_custom_shortcode_name' )

I have written a detailed article to find shortcodes in WordPress, where I have outlined getting a list of all the shortcodes available in WordPress and display them in WordPress admin.

Owner of diveinwp.com, solely responsible for creating helpful, informative content about WordPress, a fulltime WordPress developer with 8+ years of hands-on experience in WordPress design and development.