shortcode_exists() WordPress Function
The shortcode_exists() function allows you to check if a specific shortcode exists in the current post. This is useful for making sure that a shortcode is actually present before running any code that is associated with it.
shortcode_exists( string $tag ) #
Whether a registered shortcode exists named $tag
Parameters
- $tag
(string)(Required)Shortcode tag to check.
Return
(bool) Whether the given shortcode exists.
Source
File: wp-includes/shortcodes.php
function shortcode_exists( $tag ) { global $shortcode_tags; return array_key_exists( $tag, $shortcode_tags ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |