Remove all images from the_content in a post

Adding this snippet to your wordpress template index.php replacing the default the_content(); will remove images from the post. This is a great snippet if you want to display a number of images on single.php but not on the main blog view. Keep in mind that this will not remove the captions so don’t insert the images with a caption or disable all captions.

 

 

<?php
echo preg_replace('/<img[^>]+./','',get_the_content());
?>

Be Sociable, Share!

Leave a comment