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.


Top ↑

Return

(bool) Whether the given shortcode exists.


Top ↑

Source

File: wp-includes/shortcodes.php

function shortcode_exists( $tag ) {
	global $shortcode_tags;
	return array_key_exists( $tag, $shortcode_tags );
}


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.