Display the_content Without Images

Craig Martindale
Bert and Dip
1 min readNov 5, 2015

--

If you would like to only show the copy from the_content, without the images, but don’t want the stripped down excerpt which removes some of the styling, replace the_content with:

<?php
ob_start();
the_content(‘Read the full post’,true);
$postOutput = preg_replace(‘/<img[^>]+./’,’’, ob_get_contents());
ob_end_clean();
echo $postOutput;
?>

Credit: cozzy1984
https://wordpress.org/support/topic/exclude-images-from-showing-in-the_content

--

--