如何禁止 wordpress url 交换 `&` 到 `#038;`? [英] How to forbidden wordpress url exchange `&` to `#038;`?
问题描述
我想在wordpress中通过url传递一些值,但是遇到了一些麻烦,wordpress会自动将&
交换为#038;
,如何制作&
仍然是 &
吗?
I want to pass some value through url in wordpress, but I met some trouble that wordpress will exchange &
to #038;
automatically, how to make a &
still as a &
?
我注意到在wp-includes/formatting.php
中,有很多交换符号的规则,我尝试修改一些代码,但失败了.
I noticed in wp-includes/formatting.php
, there has many rules to exchange symbols, I tried modify some code, but failed.
像一些链接
site.com?this=that&that=this
将输出到网络浏览器地址,如 site.com?this=that#038that=this
site.com?this=that&that=this
will output to the web browser address like site.com?this=that#038that=this
并且页面无法获取that=this
如何正确设置?谢谢.
推荐答案
您可以禁用 wptexturize() 将其添加到模板文件夹内的 functions.php 文件中(或将其添加到现有文件夹中):
You can disable wptexturize() by adding this in a functions.php file inside your template folder (or add it to the existing one):
remove_filter('the_content', 'wptexturize');
但请注意,这当然会禁用所有清理",而不仅仅是&"转换.
But note that this will of course disable all the "cleaning", not just the '&' conversion.
如果您只想摆脱与符号的转换,您可以在formatting.php 中注释第962 行.我在下面发布了 961 和 962 行(这是来自未更改的 WP 3.1):
If you prefer to just get rid of the ampersand conversion you can comment line 962 in formatting.php. I post lines 961 and 962 bellow (this is from an unaltered WP 3.1):
// Converts lone & characters into & (a.k.a. &)
$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content);
这篇关于如何禁止 wordpress url 交换 `&` 到 `#038;`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!