WordPress如何去除文章内容html中的img?

想要提升WordPress信息流站点的用户体验,就需要去除文章内容html中的img,那么WordPress如何去除文章内容html中的img?

将下方代码添加进function即可实现:

//文章内容去除html中的img

function wpx_only_word() {

$word=get_the_content();

$less=preg_replace(“/<img.*?>/si”,””,$word);

return $less;

}

//在需要调用的地方插入下方代码

<?php echo mb_strimwidth(wpx_only_word(), 0, 300,’…’); ?>

标签

发表评论