2017-01-17 15 views
1

Wie erlauben Sie Punkte (.) In WordPress Permalinks, ich nehme an, dass es eine Funktion ist, die ich überschreiben muss, aber keine Ahnung, wie dies zu erreichen.Alle Punkte (.) In Wordpress Permalink

Es ersetzt derzeit a. mit einem -

Ich habe einen benutzerdefinierten Beitragstyp für Geschäfte wie Apple und möchten, dass der Permalink [url] /apple.com für die Geschäfte sein.

Wie kann dies erreicht werden?

Vielen Dank im Voraus für jede Hilfe.

+0

Eine Arbeits Lösung dieses Problems wurde bereits auf zur Verfügung gestellt: http://wordpress.stackexchange.com/questions/119069/allow-dot-in-wordpress-permalinks-only- für-Kategorien – CodeOut

Antwort

1
<?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])|', '---$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); 
     } 
     $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('|([^.])\.$|', '$1', $title); 
     $title = trim($title, '-'); // yes, again 
     return $title; 
} 
add_filter('sanitize_title', 'sanitize_title_with_dots_and_dashes'); ?> 

Arbeit sollte

+0

Wohin mit diesem Code? – Mohammad

+1

Du kannst es in die functions.php deines aktivierten Themes setzen – codiiv

+0

Danke, ich löste (.) Problem, aber der Beitrag gibt mir 404 keinen Bunkerfehler nach dem Bearbeiten des Permalinks. Hast du eine Ahnung davon? – Mohammad

Verwandte Themen