普通而言,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以后文章的评论数,要想获取文章的评论数必需要晓得以后文章的id,怎样...
Hana Flv Player 是一个在 WordPress 中使用比拟宽泛的播放器插件, 该插件内置了5种媒体播放器,其播放文件...
要害字形容:网站 外观 治理 切换 如何 主题 Wordpress WordPress 上一次教程咱们讲述了Wordpress友谊链接...
wordpress不同分类调用不同模板文件 用wordpress做站特地是企业站的时分,多个分类的内容不同需求显示的页面...
本文实例讲述了wordpress上一页下一页无插件分页函数。分享给大家供大家参考。详细剖析如下: 这里提供两个...
要害字形容:教程 治理 用户 权限 能够 编辑 注册 Wordpress 咱们 后面咱们讲述了 Wordpress 插件的应用。...