Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

With regards to how WP displays "preview" text on the home page, category page etc for each post, how do you stop it from including images in this section.

I'm not talking about the featured image for each post, I'm talking about if the post has any included images within the post - I don't want them to show up in the preview text.

This is the code that outputs the content for example..

<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?>
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Place following code to your theme functions.php:


function wpi_image_content_filter($content){

    if (is_home() || is_front_page()){
      $content = preg_replace("/<img[^>]+\>/i", "", $content);

    return $content;


share|improve this answer
Thanks a lot! :) – Brett Sep 26 '12 at 12:13

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.