Here in this article I going to show you, how we can remove unwanted image sizes from wordpress theme. Using code snippet, remove unwanted image sizes

How to How to remove first image from post wordpress

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.

 

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

13 thoughts on “How to How to remove first image from post wordpress”

  1. 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. Thanks a lot. That code removes the first image from displaying on the front-end, but
    – it leaves it in the Editor
    – it also doesn’t remove the caption

    Probably you may advise on some other way of removing the first picture when it is removed from the editor and when it is also removes the capture?

Leave a Reply

Your email address will not be published.