Remove ‘p’ tags around shortcodes and ‘img’

Question

I’m having trouble removing paragraph tags from around shortcodes.

I’ve tried this solution without success. How to to stop html editor from addig <p> tags to shortcodes, images, etc
and this one – the wordpress empty paragraph shortcode fix.

My shortcodes are created to have an open and close [div]—[end-div]. I’m not sure if that matters. See code example below.

add_shortcode('div', 'be_div_shortcode');
function be_div_shortcode($atts) {
    extract(shortcode_atts(array('class' => '', 'id' => '' ), $atts));
    $return = '<div';
    if (!empty($class)) $return .= ' class="'.$class.'"';
    if (!empty($id)) $return .= ' id="'.$id.'"';
    $return .= '>';
    return $return;
}
/* Close Div */
add_shortcode('end-div', 'be_end_div_shortcode');
function be_end_div_shortcode($atts) {
    return '</div>';
}

See screenshot of html: http://catalpha.com/images/code.png
See screenshot of page editor: http://catalpha.com/images/builder.png

0
Charlie 5 years 2017-01-05T08:44:49-05:00 0 Answers 50 views 0

Leave an answer

Browse
Browse