WordPress Shortcode Auto-P Issue

I am new to WordPress and am implementing a shortcode. My shortcode is super simple and the expected output is HTML5-compliant:

add_shortcode( 'my_code', function( $attributes ){
    return '<a href="#"><div></div></a>';
});

When this gets emitted, I get the following HTML:

<a href="#">
<div></div>
<p></a>

As you can see, there appears to be auto formatting going on. I have followed the advice here, here, and have installed this plugin, all to no avail. I am looking for the magic secret that is making this formatting occur. Any assistance would be appreciated!


Source: shortcode

Leave a Reply