apply_shortcodes() wordpress function and usage This text is not used because the data attribute has a value

apply_shortcodes() wordpress function and usage

Home / WordPress / WordPress Wiki / apply_shortcodes() wordpress function and usage

 

apply_shortcodes( string $content, bool $ignore_html = false )
Search content for shortcodes and filter shortcodes through their hooks.

Description

This function is an alias for do_shortcode().

See also

  • do_shortcode()

Parameters

$content

(string) (Required) Content to search for shortcodes.

$ignore_html

(bool) (Optional) When true, shortcodes inside HTML elements will be skipped.

Default value: false

Return

(string) Content with shortcodes filtered out.

Sample Usage

Here is the implementation by current method –

echo do_shortcode( '[myshrtcode]My Text[/myshrtcode]' );

And here is the usage which new WordPress 5.4 Introduces

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

Old method –

echo do_shortcode( '[wpdocs_my_shrtcode text="My Text"]', false );
echo do_shortcode( '[wpdocs_my_shrtcode]My Text[/wpdocs_my_shrtcode]', false );

WordPress 5.4 Introduces apply_shortcodes()

echo apply_shortcodes( '[wpdocs_my_shrtcode text="My Text"]', false );
echo apply_shortcodes( '[wpdocs_my_shrtcode]My Text[/wpdocs_my_shrtcode]', false );

// Displays the result of the shortcode

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments