0

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

1 Answer 1

1

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!!!

Instead:

$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>';
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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