-2

This question already has an answer here:

When I call the_content(), I want to show only text and don't want to show images. Notable that, I don't want to remove text style. The text style should be display as well. How can I do this?

marked as duplicate by cybmeta, TheDeadMedic, RRikesh, Pieter Goosen, Community Mar 10 '16 at 16:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    You could have probably googled this... – Bysander Mar 10 '16 at 13:20
3

This answer already here How to remove images from showing in a post with the_content()?

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

Add this code to your functions.php file- Add this code to your functions.php

function mdc_remove_img($content) {
    $content = preg_replace("/<img[^>]+\>/i", "", $content); 
    return $content;
}

add_filter( 'the_content', 'mdc_remove_img' );

Not the answer you're looking for? Browse other questions tagged or ask your own question.