我怎样才能建立这样的链接?
http://www.lifecellskin.us/Dev/About
“Using_Permalinks”部分,A 是大写字母。但WP会自动将大写转换为小写。
http://www.lifecellskin.us/Dev/about
我正在尝试将一个仅由 html 制作的旧网站转换为 WP 平台网站。该网站的一些链接如下所示:
该网站已被 SEO 索引。所以我不想失去SE排名。
感谢您阅读本文,并希望有人能够对此有所了解......
我给出自己问题的答案,因为我找到了解决方案。
这是下面给出的函数,将此函数添加到 `wp-includes->formating.php'
function sanitize_title_with_dashes($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);
$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);
}
//$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, '-');
return $title;
}
该函数已存在于formatting.php中,注释掉该函数并添加上述函数。 谢谢
你可以试试这个。将以下代码粘贴到您的 function.php 主题文件中。这对我有用。
// Remove existing filter
remove_filter( 'sanitize_title', 'sanitize_title_with_dashes' );
// Function to maintain capitalization in slugs
function maintain_capitalization_slug($title, $raw_title, $context) {
// Apply only when saving slugs
if ($context === 'save') {
// Preserve capitalization and replace special characters with hyphens
$title = preg_replace('/[^a-zA-Z0-9]+/', '-', $raw_title); // Replace non-alphanumeric characters with hyphens
$title = trim($title, '-'); // Trim leading/trailing hyphens
}
return $title;
}
// Apply the custom function to 'sanitize_title'
add_filter('sanitize_title', 'maintain_capitalization_slug', 10, 3);
文件:wp-includes/formatting.php
826路
$title = mb_strtolower($title, 'UTF-8');
注释掉该行