img
Home / Internet / Web Development / Removing first image from the_content() in wordpress

Removing first image from the_content() in wordpress

/
/
/
15 Views

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);
}

 

  • Facebook
  • Twitter
  • Google+
  • Linkedin
  • Pinterest

Leave a Comment

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

It is main inner container footer text