Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress shortcode function: echo vs return
<?php
// Don't use echo in the shortcodes. If you have to, use ob_start() / return ob_get_clean()
add_shortcode('test', 'my_test_func');
function my_test_func( $args ) {
ob_start();
?>
your content / html / etc
<?php
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.