How to Output HTML tags in do_shortcode?

Yes it is possible.

There are two ways that I can think of at this moment.

First follow what the codex says Shortcodes.
Basically you just wrap your html in ob_start(); this will return the html as a string so you can echo it.

function my_shortcode() {
    ob_start();
    ?> <HTML> <here> ... <?php
    return ob_get_clean();
}

The second way is to add your html as a string to a variable then return it later. eg.

function my_shortcode() {
    $output="";
    $output.= '<html>content</html>';
    return $output;
}

Leave a Comment