Home > Uncategorized > Function Reference/do shortcode

Function Reference/do shortcode

Usage

<?php echo do_shortcode( $content ) ?>

Parameters

$content
(string) (required) Content to search for shortcodes

Default: None

Return Values

(string) 
Content with shortcodes replaced by the output from the shortcode’s handler(s).

Examples

add_filter('the_content', 'do_shortcode', 11); // From shortcodes.php
// Use shortcode in a PHP file (outside the post editor).
echo do_shortcode('');
// 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');

Notes

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.

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: