普通而言,WordPress自身会对英语用户的体验进行优化,例如默许模板的分隔符永远都是“|”,由于英文单词以空格空开,要区分两个单词不可能用“-”,因而“|”是最好的抉择。同样,为了让URL更合乎阅读器解析和用户的辨认,wordpress默许会将题目中的英文大写字母lower到小写。
但是关于中文网站来说,这或者不是一件很好的是,假如要在URL中应用中文,那么应用大写也是常有的,这里提供一种勾销wordpress主动降级字母大写的办法。
remove_filter( 'sanitize_title', 'sanitize_title_with_dashes' );
add_filter( 'sanitize_title', 'use_capital_letter_in_slug' );
function use_capital_letter_in_slug($title) {
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);</p>
<p> $title = remove_accents($title);
if (seems_utf8($title)) {
//if (function_exists('mb_strtolower')) {
// $title = mb_strtolower($title, 'UTF-8');
//}
$title = utf8_uri_encode($title, 200);
}</p>
<p> //$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title); // kill entities
$title = str_replace('.', '-', $title);
// Keep upper-case chars too!
$title = preg_replace('/[^%a-zA-Z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');</p>
<p> return $title;
}
将下面的代码拷贝到你的主题文件functions.php中,它即可勾销wordpress对postname的格局化,同样,它也对分类、标签等的别名起作用。
以上就是安达网络工作室关于《wordpress在postname中支持大写字母的方法》的一些看法。更多内容请查看本栏目更多内容!
家喻户晓,wordpress是基于php开发,在apache效劳下运转是最优秀的。然而,国际依然有很多主机上不能提供ap...
WordPress菜单CSS类选项设置办法: 1、点开WordPress菜单设置页面右上角“显示选项”,勾选外面的...
1. 代码形式第一步,关上wp-config.php,增加复制代码代码如下:define('SAVEQUERIES', true);开启SAVEQUERI...
明天收到了很多Bloger冤家的E-mail拜年短信,嘿嘿,觉得很好玩,可是他们是如何完成的这个呢,很简略的,可...
wordpress完成随机文章 ralix曾公布过对于wordpress随机文章的相干插件的点评文章(“wordpress插件之...
本文实例讲述了wordpress晋级后明码正确后盾无奈登陆的处理办法。分享给大家供大家参考。详细剖析如下: 明...