I am trying to mask some affiliate URLs by appending a category to the end of the domain and then appending the post title:
For example, my website is 'www.domain.com'
I have a post at 'www.domain.com/post1'
When I add the category it becomes 'www.domain.com/recommends' and I want to then append post1 to the end like 'www.domain.com/recommends/post1'
My anchor text looks like this:
<a href="http://www.domain.com/recommends/<?php echo strtolower(get_the_title()); ?>">Visit <?php the_title(); ?></a>
But my url doesn't keep the hyphens in the title. If the post title has a space, then the output url puts %20 instead of a hyphen.
Any suggestions?