如何从_Content()中仅删除图像 时间:2016-03-10 作者:Md Jwel Miah 调用\\u content()时,我只想显示文本,不想显示图像。值得注意的是,我不想删除文本样式。文本样式也应显示。我该怎么做? 2 个回复 最合适的回答,由SO网友:Kishan Chauhan 整理而成 这个答案已经在这里了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; ?> SO网友:mukto90 将此代码添加到functions.phpfunction mdc_remove_img($content) { $content = preg_replace("/<img[^>]+\\>/i", "", $content); return $content; } add_filter( \'the_content\', \'mdc_remove_img\' ); 文章导航