Share this Article
WordPress shortcodes are square bracket strings ([ ]) that magically transform into something fascinating on the frontend. In this tutorial we will see how to check a shortcode which really exists or not.
To check wordpress shortcode exists or not, a function is available in wordpress i.e shortcode_exists().
Syntax
shortcode_exists( string $tag )
Whether a registered shortcode exists named $tag.
Example
<?php
if ( shortcode_exists( 'gallery' ) ) {
// The shortcode [gallery] exists.
}
?>
This function returns boolean value means either true or false. If supplied shortcode exists then returned value will be true otherwise it will be false.
Was this post helpful?
Let us know if you liked the post. Please share your feedback.