In many wordpress old site they used the first image as post or featured image so while showing the single post they not want to show the first image which is uploaded.

remove first image from wordpress post

remove first image from wordpress post

Using following code you can remove the first image from wordpress post. Please put following code in to functions.php file (you will find this file in your theme folder)

function remove_first_image ($content) {
if (!is_page() && !is_feed() && !is_feed() && !is_home()) {
$content = preg_replace("/<img[^>]+>/i", "", $content, 1);
} return $content;
add_filter('the_content', 'remove_first_image');

when you see the single page of blog then you will not see the first image from blog post.


Written by Purab Kharat

I Purab am from India, Pune. I am WordPress and Drupal Architect and consultant. I worked on many technologies like Ruby on Rails, Flex, PHP, jQuery etc... Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA.I contributed to many wordpress plugins and Drupal Modules. I contributed to Drupal core also.Connect to purab on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to or Chat with me on Skype : purabdk

This article has 5 comments

  1. Gianpiero Reply

    Hi and thanks for this solution. Can I ask you a question?
    Do you have a solution to do not show a thumbnail post at the top of it? If I insert a featured image in a post, automatically wordpress show it another time in the post. Why? Can you help me, please? Thanks

Leave a Comment

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>