HELP ME PLEASE - passing a dynamic value into a href

Hi, just a PHP quickie really, involving WordPress. Let me try to explain:

The Situation:

  • I have a wordpress custom field (called ‘ref’) which holds a reference number entered by the post author.
  • Within each post is a button which takes the user to a form located on another page. Currently the link to do this is <a href=“otherPage.html”>form page</a>
  • Within the form on the other page is a field with an id of ‘ref’, where the user is required to enter a reference number.

The Aim:
What I would like to do is take the value of the ‘ref’ custom field (from the wordpress post), and call it within the href of the button that takes the user to the form page.

Desired Result:
So that when the user clicks this button in the blog post and is taken to the form on another page, the ‘ref’ field’s value is that of the ‘ref’ wordpress custom field.

I know how to pass data from a link (href) to a specific form field (specifying the ref field’s value directly in the button link itself for instance), but because each blog post’s ‘ref’ is to be unique, I cant specify the unique ref in the button’s link code, as - it needs to be taken from the ref custom field, which changes each time, you know?

If that makes sense to you and your still with me, I would really appreciate any advice or help as figuring out how to do this has got my head done in! :injured:

Many Thanks! :slight_smile:

EDIT:
PS: Here is the code (from my wordpress theme) of the custom field button taking you to the other page (with the form on it). I assume the coding would need to go in the href of this button to pass the ref value onto the form field.


<?php $Btn_Form = get_post_meta($post->ID, 'Btn_Form', $single = true); ?>
<?php if($Btn_Form !== '') { ?>  
     <a href="[COLOR="DarkRed"]otherpagewithform.php[/COLOR][COLOR="Red"]?Ref=<?php echo $Ref;?>[/COLOR]" 
        title="Go to form page"><?php echo $Btn_Form;?></a>
<?php } ?>