apply_shortcodes()WP 5.4.0

Search content for shortcodes and filter shortcodes through their hooks.

This function is an alias for do_shortcode().

1 time — 0.0004201 sec (fast) | 50000 times — 0.67 sec (very fast)

No Hooks.

Return

String. Content with shortcodes filtered out.

Usage

apply_shortcodes( $content, $ignore_html );
$content(string) (required)
Content to search for shortcodes.
$ignore_html(true|false)
When true, shortcodes inside HTML elements will be skipped.
Default: false

Examples

0

#1 Processing an individual shortcode

Using a shortcode in a PHP file, outside the content, when you want to get the shortcode output separately.

This example shows how to process a shortcode from PHP code. For example, if you want to output a shortcode somewhere custom in the template.

echo apply_shortcodes( '[somename]' );

Example with shortcode parameters:

echo apply_shortcodes( '[contact-form-7 id="91" title="quote"]' );

Example for content shortcode:

echo apply_shortcodes( '[myshrtcode]My Text[/myshrtcode]' );
// Displays the result of the shortcode
0

#2 More examples

apply_shortcodes() is an alias of do_shortcode(), so see examples of do_shortcode().

Notes

Changelog

Since 5.4.0 Introduced.

apply_shortcodes() code WP 6.4.3

function apply_shortcodes( $content, $ignore_html = false ) {
	return do_shortcode( $content, $ignore_html );
}