Shortcode Already Exists in WordPress

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().


shortcode_exists( string $tag )

Whether a registered shortcode exists named $tag.


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.

Learn Web Development Courses @ $4 only.
Web Development Courses @ $4