• When using a shortcode in slide content, the resulting output gets wrapped in paragraph tags, presumably by wpautop, but doesn’t have the tags removed by shortcode_unautop. My shortcode function is called twice – from two shortcodes. The first starts a div to go before content, the second closes the div after the content.

    The result is that I get:

    <p><div></p>
    content goes here
    <p></div></p>

    whereas I should get:

    <div>
    content
    </div>

    There are lots of results for a “remove unwanted p tags wordpress” search but none of the solutions work in this case, because the shortcode is nested inside Slide Anything’s shortcode.

    Any ideas welcomed…

    thanks,

    Martin

    • This topic was modified 6 years, 9 months ago by therealskid.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author simonpedge

    (@simonpedge)

    Ok, I understand the problem…

    BUT if I added “shortcode_unautop()” to slider content (when the ‘Allow Shortcodes’ option is checked), this could potentially affect sliders that other people have already created on their sites and have styled accordingly (with the “<p>” tags included).

    So I will need to investigate adding this as an extra option – maybe a “Shortcode unautop” checkbox option.

    Could you do me a favour and test whether this code change will work in your case? Please edit the file /wp-content/plugins/slide-anything/php/slide-anything-frontend.php, and on lines 66-71 you will see:

    // apply 'the_content' filter to slide content to process any shortcodes
    if ($slide_data['shortcodes'] == 'true') {
    	$slide_data["slide".$i."_content"] = do_shortcode($metadata["sa_slide".$i."_content"][0]);
    } else {
    	$slide_data["slide".$i."_content"] = $metadata["sa_slide".$i."_content"][0];
    }

    Change line 68 to be:
    $slide_data["slide".$i."_content"] = shortcode_unautop(do_shortcode($metadata["sa_slide".$i."_content"][0]));

    If this works for you, I’ll look to adding this option.

    Thread Starter therealskid

    (@therealskid)

    Thanks for getting back to me.

    I’ve tried making the change to the code but unfortunately still with the same result.

    One thing I didn’t mention in my original post (due to trying to illustrate the simplest way of reproducing the issue) is that I’m actually wrapping the whole thing in another div…

    <div class="col-width">
        <div class="slide-text">
           content
        </div>
    </div>

    However, removing the outer div doesn’t make any difference.

    If you would like a login to have a closer look, please let me know.

    Thanks,

    Martin

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘prevent shortcode being wrapped in p tags’ is closed to new replies.