Friday, April 19, 2024
Wordpress Tricks

How to remove image from wordpress post content?

How to add custom meta title and meta description in Wordpress?

Remove image from wordpress post content

Hello to all, welcome to In this post, I will tell you, How to remove image from wordpress post content? 

Here is the working code and you can add this into your wordpress theme’s any template file:
$content = get_post_field('post_content', $post_id);
$content = preg_replace("/<img[^>]+\>/i", "", $content);


$content = get_the_content();
$content = preg_replace("/<img[^>]+\>/i", " ", $content);          
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;

 If you any query related to wordpress then comment or email me.

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.