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

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
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;

From http://wordpress.org/support/topic/how-to-hide-images-from-front-page

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.