how to remove images from wordpress post content

WordPress tutorial, how to remove images from wordpress post content. Some time we want to remove the images from wordpress post. Given code here in article.

I got following code for removing the images from post. you can use following code in single.php or page.php file.

how to remove images from wordpress post content

how to remove images from wordpress post content

how to remove images from wordpress post content


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

Add a Comment

Your email address will not be published. Required fields are marked *