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
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.
Great!!! thnx! Ive been looking for this code the whole day
I was looking for this code from some time. I kindly thank you! Appreciate! Best to you.
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
I will write post about this…If you have any issue then write to me on wordpressapi@gmail.com
Hi, could this code be edited to work for a specific category only?
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?
this code will remove images from only post not on home page and pages
Do you have a solution to do not show a thumbnail post at the top of it?
I did not got your question clearly…can you explain more.
Thanks alot man it reall works for me
Thanks Dude ! Very Very Thanks My Prob. is Solved
http://techandtweet.in
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?
I will work on that…update the code..thanks for reply