WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

Is there a way i can get the_permalink as a variable? I need to build an info window with it but it wont appear in the $infoWindow variable...

    $link = the_permalink($post->ID); // prints out into html
    $infoWindow = '<div><h2><a href="'.$link.'">'.$post->post_title.'</a></h2></div>';
<script type="text/javascript">
    marker = [<?=$v_latitude?>, <?=$v_longitude?>,"",'<?=$infoWindow?>'];

best, Dc

share|improve this question

Use get_permalink() instead. (Codex ref.)

Per the WordPress function-naming convention, most functions have two forms: the_*() and get_*(); the the_*() functions will print the output, and the get_*() functions will return the output.

share|improve this answer
oh god - code blind. Thanks Chip! – daniel Crabbe Jun 29 '11 at 13:20

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.