I've built a custom theme and it works fine apart from WordPress injecting unwanted <p> tags on the page before the post loop starts. On top of that, it adds the word 'Save' eg: <p>Save</p>, I've tried using remove_filter( 'the_excerpt', 'wpautop' ); in functions, but that only removes the <p> tags not the content.

<ul class="grid">
<?php query_posts('showposts=12&offset=6&post_type=post'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  <?php the_excerpt(); ?>
<?php endwhile; else: ?>
  <h6>no more.....</h6>

<?php endif; ?>

if( have_posts() ):

while( have_posts() ): the_post(); ?>

  <li class="grid__item">
  <div class="roster__link">
      <img class="roster__image"><?php the_content(); ?>
        <?php $value = get_post_meta( $post->ID, 'URL', true );

         if ( $value ) {
             $url = esc_url( 'http://' . $value );
             if ( '' !== $url ) {
                 print "<a href='$url' target='_blank'>$display";

      <div class="text-wrap">
        <div class="text">
          <p><?php the_title(); ?></p>


 <?php endwhile;



  • I am not sure I understood you questions. Can you please be more descriptive. Add screenshots if you can. Looks like screenshots will help in here Commented Aug 24, 2016 at 9:55
  • @MarutiMohanty thanks, added the code where the problem seems to stem from, I'm new to this so apologies if my answers aren't clear...
    – r3sende
    Commented Aug 24, 2016 at 10:20

1 Answer 1


Try this instead: remove_filter ('the_content', 'wpautop');

You can also look at your page.php or template file and investigate which elements/tags are being used.

Hope this helps!

  • Thanks Jake, tried that, it does remove the <p> tags but Wordpress still adds the word 'Save' to the page.
    – r3sende
    Commented Aug 24, 2016 at 10:24
  • It most likely only shows if your the admin. Hard to debug without looking through all of your code, but try logging out/incognito and see if it shows up for normal users.
    – jake
    Commented Aug 24, 2016 at 10:35
  • Figured it out, I was looping through things twice and <?php the_excerpt(); ?> was printing <p>Save</p> to the page. All fixed, thanks for your help
    – r3sende
    Commented Aug 24, 2016 at 11:25
  • No problem :) glad you figured it out
    – jake
    Commented Aug 24, 2016 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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