esc_url removes white space. Can I change that to using ‘-‘?

$url = esc_url ( str_replace(' ' , '-', $url ) );

Replace the spaces to – chars before activating esc_url function, and your problem is solved.

Leave a Comment