WordPress.org

Support

Support » How-To and Troubleshooting » Remove international characters from slug – Almost done – Bit help

Remove international characters from slug – Almost done – Bit help

  • Hello,

    I want to remove some characters from the slug, like “¿” that we use in spanish for opening a question.

    If I go to wp-includes/formatting.php and in
    function sanitize_title_with_dashes($title) line 820 wp32
    I add this
    $title = str_replace('¿', '', $title);
    just before
    $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);

    And it is working correctly. So when I write in the title “¿Qué tal?” the slug is “que-tal”

    Now, how to do it with a function so I can use it via functions.php or via a plugin??

    I am doing this but it is not working

    function limpiar_slug($slug)
    {
    	$slug = str_replace('¿', '', $slug);
    	return $slug;
    }
    
    add_filter('sanitize_title_with_dashes', 'limpiar_slug');

    Any suggestion???

    Thanks in advance

  • The topic ‘Remove international characters from slug – Almost done – Bit help’ is closed to new replies.