Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using esc_url to sanitize my url. The only problem is that "my link" becomes "mylink". I wouldreally like it to become "my-link".

Is there a way to change this?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted
$url = esc_url ( str_replace(' ' , '-', $url ) );

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

share|improve this answer
    
I know - I was hoping that esc_url had a function so I didn't have to use str_replace. Thanks for your answer. –  Steven Apr 7 '11 at 21:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.