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.



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

Leave a comment