I have one online version of a site, and one developer version which I am working and making changes on.

If I have a form with a url which the user will be redirected to:

 <input type="hidden" name="cancelurl" value="https://mytemporarysite.com/cancel/">

So when updating the live site, I have to change the url to the one that's valid for the live version.

So it would be more preferrable to use a variable or constant which is defined somewhere.

<input type="hidden" name="cancelurl" value="<?php $cancelurl ?>">

Then I can transfer the code without having to change the urls.

So my question is where and how do I define such variables or constants?

1 Answer 1


I believe you can just use site_url() + the path - so for instance:

<input type="hidden" name="cancelurl" value="<?php echo site_url('/cancel/'); ?>">
  • Okay, that should work! Beause i's the same folder structure. And the page is directly in the main folder. Why didn't I think of that? If the page would have been in a different folder on each site, I would have needed some other solution, but this will solve the problem I think.
    – Galivan
    Dec 1, 2015 at 21:58
  • Yeah, it's amazing how many variables/constants WordPress supplies. I just found this: codex.wordpress.org/Determining_Plugin_and_Content_Directories
    – Michelle
    Dec 1, 2015 at 22:19
  • Btw, I ended up using "home_url()" because "site_url()" added "/wp" to the domain name.
    – Galivan
    Dec 2, 2015 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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