Wordpress 中的所有点 (.)

All dots(.) in Wordpress Permalink

如何在 WordPress 永久链接中使用点 (.),我假设这是一个我需要覆盖的函数,但不知道如何实现。

它目前取代了 .用 -

我有一个自定义 post 类型的商店,例如 apple,我希望商店的固定链接是 [url]/apple.com。

如何实现?

提前感谢您的帮助。

<?php 

remove_filter('sanitize_title', 'sanitize_title_with_dashes');
function sanitize_title_with_dots_and_dashes($title) {
        $title = strip_tags($title);
        // Preserve escaped octets.
        $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '------', $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])---|', '%', $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);
        }
        $title = strtolower($title);
        $title = preg_replace('/&.+?;/', '', $title); // kill entities
        $title = preg_replace('/[^%a-z0-9 ._-]/', '', $title);
        $title = preg_replace('/\s+/', '-', $title);
        $title = preg_replace('|-+|', '-', $title);
        $title = trim($title, '-');
        $title = str_replace('-.-', '.', $title);
        $title = str_replace('-.', '.', $title);
        $title = str_replace('.-', '.', $title);
        $title = preg_replace('|([^.])\.$|', '', $title);
        $title = trim($title, '-'); // yes, again
        return $title;
}
add_filter('sanitize_title', 'sanitize_title_with_dots_and_dashes'); ?>

应该可以