Search code examples
phpwordpresscontact-form-7

Pass current page URL on click to CF7


Hi I'm using CF7 Dynamic Text Extension.

I have a call back button that goes to a CF7 Form, but I need to know the URL that the click came from. Currently using the code below

<?php echo '<a style="background: rgba(0, 0, 0, .1);color:#000000;" href="/call-back-request/ context='.urlencode(get_the_title($post->ID)) .'">Request Callback</a>'; ?>

However there are titles that are the same, so I really need the URL to tell us exactly what the contact is related to.


Solution

  • Instead of

    get_the_title($post->ID)
    

    Make it

    get_permalink($post->ID)