从帖子中删除the_content的所有图像?
您好,我想帮助创建一个插件,以自动删除帖子中的所有图像。
可能的解决方案将此代码添加到您的主题的index.php文件:
?php>
echo preg_replace('/<img[^>]+./','',get_the_content());
?>
将此代码转换为插件?
Hello I want help to create a plugin to automatically remove all the images in the postings.
Possible solution add this code to your theme’s index.php file:
?php>
echo preg_replace('/<img[^>]+./','',get_the_content());
?>
Convert this code into a plugin??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为此purporse使用
wp_kses
。使用WP_KSES_ALLOD_HTML
filter添加img
元素的过滤器。在您的functions.php中。
然后在index.php中。
You can use the
wp_kses
for this purporse. Add the filter for theimg
element using thewp_kses_allowed_html
filter.In your functions.php.
Then in index.php.