shortcode_exists()
Checks if the specified shortcode is registered.
More details about shortcodes.
1 time — 0.000011 sec (very fast) | 50000 times — 0.02 sec (speed of light) | PHP 7.1.5, WP 4.8.2
No Hooks.
Returns
true|false
. true or false, depending on whether the shortcode exists or not.
Usage
if ( shortcode_exists( $tag ) ) { }
- $tag(string) (required)
- The name of the shortcode to check.
Examples
#1 Check if the shortcode gallery
exists (registered):
if ( shortcode_exists( 'gallery' ) ) { // shortcode [gallery] is registered. }
Notes
- Global. Array. $shortcode_tags List of shortcode tags and their callback hooks.
Changelog
Since 3.6.0 | Introduced. |
shortcode_exists() shortcode exists code WP 6.8.1
function shortcode_exists( $tag ) { global $shortcode_tags; return array_key_exists( $tag, $shortcode_tags ); }