WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this code for insert a permalink but doesn't work, return exactly code:

$text = '<form><td>Permalink to: <?php the_title();?></td><textarea cols="85" rows="2" readonly="readonly" onclick="select()"/><?php echo $permalink = get_permalink( $id ); ?></textarea></form>';  

This is what currently shows up: Screenshot

share|improve this question
up vote 1 down vote accepted

A better, cleaner way to do this would be to use proper string return methods and concatenation. I say this, because you're trying to put functions that echo content (i.e. the_title() into a variable - this won't work!!!


$text = '<form><td>Permalink to: ';
$text .= get_the_title();
$text .='</td><textarea cols="85" rows="2" readonly="readonly" onclick="select()"/>';
$text .= get_permalink( $id );
$text .= '</textarea></form>';

Or, if you absolutely must have this in one long line:

$text = '<form><td>Permalink to: ' . get_the_title() . '</td><textarea cols="85" rows="2" readonly="readonly" onclick="select()"/>' . get_permalink( $id ) . '</textarea></form>';
share|improve this answer
thanks so much =) – luca Apr 27 '12 at 18:48

Your Answer


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.