can i use html tags in shortcode attributes? like this:

function b_text( $atts, $content = null ) {
  extract( shortcode_atts( array(
    'text' => '<div class="myClass">DOM</div>'
  ), $atts ) );

    <div> <?php echo $text; ?></div>

  $content = ob_get_contents();
  return $content;

add_shortcode('b-text', 'b_text');

Probably i can use some actions or filters to redefine my html content in atts? it is at all possible? thanks!

1 Answer 1


While it is a technically possibility, it's most likely direction that isn't worth it.

Overuse of shortcodes for what is essentially (crappy) templating is problematic and has a history of security issues.

In recent months there has been ongoing planning and discussion about possibility of changes to shortocde syntax and mechanics in core. HTML in attributes is explicitly named as one of the problems that led to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.