Skip to content

Instantly share code, notes, and snippets.

@julian-stark
Created July 17, 2020 11:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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