add_shortcode

SummerySummery

Adds a new shortcode.

Syntax

add_shortcode( string $tag, callable $callback )

DescriptionDescription

Care should be taken through prefixing or other means to ensure that the shortcode tag being added is unique and will not conflict with other, already-added shortcode tags. In the event of a duplicated tag, the tag loaded last will take precedence.

ParametersParameters

$tag

(string) (Required) Shortcode tag to be searched in post content.

$callback

(callable) (Required) The callback function to run when the shortcode is found. Every shortcode callback is passed three parameters by default, including an array of attributes ($atts), the shortcode content or null if not set ($content), and finally the shortcode tag itself ($shortcode_tag), in that order.

SourceSource

File: wp-includes/shortcodes.php


			

ChangelogChangelog

Changelog
Version Description
2.5.0 Introduced.
Scroll to Top