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.

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
add comment

1 Answer

up vote 1 down vote accepted

Place following code to your theme functions.php:

add_filter('the_content','wpi_image_content_filter',11);

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