wordpress - apply_filters 不会替换默认小部件中的文本
问题描述
我正在尝试删除 WP_Widget_Recent_Comments 在二十个主题中显示的“on”文本字符串(使用修改的字体):
我正在尝试在我的子主题的functions.php 中执行此操作。我发现 WP 在那里创建了这个字符串: \wp-includes\widgets\class-wp-widget-recent-comments.php 148
$output .= sprintf(
_x( '%1$s on %2$s', 'widgets' ),
我在我的子主题 fuctions.php 中搜索并尝试了 100500 种不同的 apply_filters 变体,例如:
apply_filters('widget_text_content', 'replace_text');
function replace_text($text) {
$text = str_replace('on','', $text);
return $text;
}
但它们都不适用于这个小部件。同时,常规 apply_filters 到 'the_content' 过滤器工作正常。请帮忙 :)
解决方案
推荐阅读
- python - 在 python 3 中,字符串输入 'python' &python 的区别
- r - 在 R 中使用 drm 包进行逆预测
- javascript - 在 Chart js 中更新图表
- python - 如何在 Python 中合并多个列表
- loopbackjs - 将 LoopBack 应用程序连接到现有 MySQL 数据库
- string - 使用 PowerShell 将字符串解析为对象时遇到问题
- python - Python 函数中的输入参数
- makefile - 将路径字符串列表解析为make中不同路径的更好方法?
- r - rbind 一个空的 xts 和一个 xts
- c++ - 在类定义中推导内联静态成员函数的返回类型