Define Shortcode with Output using ob_start Output Buffering

function my_shortcode() { ob_start(); echo 'hello world'; echo 'This is a WordPress shortcode'; $output_string = ob_get_contents(); ob_end_clean(); return $output_string; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.