Removing first image from the_content() in wordpress

0
2
Remove image from the_content() in wordpress

If you are looking to remove the image from the_content() in WordPress however still want to show the featured image then here is the nice and simple function that you can either use within functions.php file to make it work throughout the website or can use in individual WordPress template to make it effect on specific section or page by calling the function in proper place within the template.

add_filter(‘the_content’, ‘remove_photo’);

function remove_photo($content)
{
return preg_replace(‘/<img[^>]+./’, ”, $content);
}

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here