wordpress tutorial, remove first image from post wordpress. In many wordpress old site they used the first image as post or featured image. Here solution. while showing the single post they not want to show the first image which is uploaded.

How to remove first image from post wordpress

How to remove first image from post wordpress

How to remove first image from post wordpress

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 WPAPI

My name is Purab Kharat, Here is my Personal Blog: digcms.com. Work as an Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to purab on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to purabdk@gmail.com or Chat with me on Skype : purabdk

This article has 10 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

  2. Richard Reply

    This code did remove the image, but it also removed all the line breaks in the text.

    Any suggestions for altering to prevent it doing so?

Leave a Comment

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