jungledsales
Member
Posted 4 years ago #
I am trying to attach the post title to a URL but the output URL does not maintain the correct hyphens in between each word.
<a href="http://www.domain.com/recommends/<?php echo strtolower(get_the_title()); ?>">Visit <?php the_title(); ?></a> | <a href="#review">Submit your review</a>
Maybe there is a way to save "http://www.domain.com" as a URL and append the title to that URL? I'm stumped. Suggestions?
Why not use a permalink tag (the_permalink or get_permalink)? Your other option is to use php str_replace.
jungledsales
Member
Posted 4 years ago #
Because the permalink is not the same as my desired URL. The permalink would be http://www.domain.com/post1 and I want the output URL to be http://www.domain.com/recommends/post1
So I just need a way to grab the post title and append it to a URL. But without losing the hyphens.
I'll play a little more with str_replace but I don't think that will work.
No, you don't want "the title". You want the "slug"!
http://wordpress.org/support/topic/128046?replies=8
jungledsales
Member
Posted 4 years ago #
Beautiful! It works. Thanks.