2010-07-25 65 views
4

我有一个Wordpress页面的标题“纸10x10”。在我的边栏导航中,此页面显示为“纸张10×10”(请注意,x由Wordpress进行了纹理化处理,因此x变成了乘号×)。WordPress的:全球禁用wptexturize

我有插件原始html插件已安装。它只会禁用the_content的wptexturizing。但导航不在the_content中,而是在get_sidebar()中。

我试图remove_filter:

remove_filter('the_content', 'wptexturize'); 
remove_filter('the_excerpt', 'wptexturize'); 

但是,这也只是禁止组织化的内容或摘录。

如何在我的WordPress博客中全局禁用wptexturize筛选器?

回答

5

尝试:

remove_filter('the_title', 'wptexturize'); 
+0

感谢,该诀窍。愚蠢的我。尴尬,我没有事先尝试。对不起,你的时间家伙,再次感谢windyjonas! – Max 2010-07-25 21:15:40

4

我去/wp-includes/default-filters.php,寻找受wptexturize的一切,并在相同的风格default-filters.php做了foreach使用添加过滤器。

你的问题似乎已经解决,但其他人可能最终要完全清除,所以我在这里张贴,它是第一个问题上来寻找wptexturize时:

$filters_to_remove = array(
    'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title', 
    'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description', 
    'term_description', 
    'the_title', 'the_content', 'the_excerpt', 'comment_text', 'list_cats' 
); 

foreach ($filters_to_remove as $a_filter){ 
    remove_filter($a_filter, 'wptexturize'); 
} 
+0

如果其中一个过滤器不存在,是否会造成问题?它会导致一个PHP错误?我担心过滤器是否会在更新中消失。此外,这不会阻止wp在我的段落标记中的文字周围添加双引号。是否有另一个过滤器? – isimmons 2013-06-22 22:54:43

+0

不要介意报价。那是铬devtools。但我仍然怀疑是否应该检查以确保过滤器存在。目前只是不确定如何做到这一点。 – isimmons 2013-06-22 23:06:24

+1

在关于remove_filter的文档中,它表示它只是在失败时返回false,所以在WordPress更新之后,您的站点上无处不在出现丑陋的PHP警告。您可以在此处看到: http://codex.wordpress.org/Function_Reference/remove_filter 和这里,行240到273: http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/plugin.php#L0 – Pabbles 2013-06-24 00:40:00

6

你可以用run_wptexturize过滤全局禁用它,as detailed here

add_filter('run_wptexturize', '__return_false');

+0

这是确保插件不会无意中转向的唯一方法重新启动wptexturize过滤器,并全局禁用过滤器。 – JJJ 2015-08-07 13:35:12

+0

非常简单和全球,谢谢! – 2016-11-19 23:48:05

+0

哇!据我所知,这比其他解决方案更好。 – elpoto 2017-09-01 09:06:27