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' )

You can also check, Get a list of all the active shortcodes in WordPress

Share it to the Community!

Advertisement

Related Posts

Leave a Reply

Your email address will not be published.

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top