0

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' ) ); ?>

1 Answer 1

1

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

0

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.