apply_shortcodes()
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
#1 More examples
apply_shortcodes() is an alias of do_shortcode(), so see examples of do_shortcode().
#2 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
Notes
- See: do_shortcode()
Changelog
Since 5.4.0 | Introduced. |
apply_shortcodes() apply shortcodes code WP 6.7.1
function apply_shortcodes( $content, $ignore_html = false ) { return do_shortcode( $content, $ignore_html ); }