0
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99 );
add_filter( 'the_content', 'shortcode_unautop', 100 );

Work for almost all my shortcodes excluding one that returns a list of custom post type thumbnails like this:

<li>
    <a href="#">
       <div class="image-container">
          <div class="image"></div>
          <div class="overlay"></div>
        </div>
    <p></a>
</li>

No matter what I do it always adds this <p> before </a> despite returning them inline (I don't even have single space between them in my shortcode source, eg.

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <li><a href="#"><div class="image-container"><div class="image"></div><div class="overlay"></div></div></a></li>

<?php endwhile; ?>

Is there any way of removing this empty P from my shortcodes output?

0

I think it's because of invalid markup. autop is trying (poorly) to fix code. Change your divs to spans and in your stylesheet set them as block.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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