WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
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:

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

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

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

Your Answer


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.