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.

If I have a post with a spacing in it (like: Hello World), than get_the_title shows me only "Hello" as a link and not the whole permalink. I already tried using a substring to get it done, but it did not work out for me. Am I missing here something?

I just used get_the_title(); and put it in a variable.

Code:

<?php
$titletest = get_the_title();

echo " <a href=http://www.testungsss.com/search?q=$titletest>$titletest</a> ";
?>
share|improve this question
1  
show us your code. –  Milo Jun 16 '13 at 16:28
    
There is not much to show really. I updated my code. –  user1627363 Jun 16 '13 at 16:38

1 Answer 1

up vote 3 down vote accepted

Your title isn't correctly encoded for use in a query variable. Try this:

echo ' <a href="http://www.testungsss.com/search?q=' . urlencode($titletest) . '">' . $titletest . '</a>';
share|improve this answer
    
Thanks, it works! –  user1627363 Jun 27 '13 at 13:20

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.