Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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