This page redirects to an external site: https://developer.wordpress.org/reference/functions/do_shortcode/
Languages: English • Italiano • 日本語 (Add your language)
Searches content for shortcodes and filters shortcodes through their hooks.
<code style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">do_shortcode</span><span style="color: #007700">( </span><span style="color: #0000BB">$content </span><span style="color: #007700">) </span><span style="color: #0000BB">?></span></code>
add_filter( 'the_content', 'do_shortcode', 11 ); // From shortcodes.php
// Use shortcode in a PHP file (outside the post editor). echo do_shortcode( '[gallery]' );
// In case there is opening and closing shortcode. echo do_shortcode( '[iscorrect]' . $text_to_be_wrapped_in_shortcode . '[/iscorrect]' );
// Use shortcodes in text widgets. add_filter( 'widget_text', 'do_shortcode' );
// Use shortcodes in form like Landing Page Template. echo do_shortcode( '[contact-form-7 id="91" title="quote"]' );
There is an exception to the built in embed shortcode available with WordPress. In order to use this shortcode with do_shortcode, you can do the following:
$embedurl = 'http://yourembeddableurl.com';
if (!empty($embedurl)) {
$var = apply_filters('the_content', "[embed]" . $embedurl . "[/embed]");
echo $var;
}
If there are no shortcode tags defined, then the content will be returned without any filtering. This might cause issues if a plugin is disabled as its shortcode will still show up in the post or content.
Since: 2.5
do_shortcode() is located in wp-includes/shortcodes.php.