I created a field in WP customizer and I'm trying to pull whatever value I enter from another file. Beforehand, this worked:
private $endpoint = "http://www.website.com/webservice/GetSearchResults.htm?ws-id=12345";
and now I am trying to do something like this (I'm new at this):
$website_api_key = echo get_theme_mod('website-api-key');
private $endpoint = "http://www.website.com/webservice/GetSearchResults.htm?ws-id=" . $website_api_key;
How do I get this to work correctly?
You are setting the variable in the url correctly. Now you just have to grab it. When you visit a webpage, you are using a GET request, so these "url variables" can be grabbed through the $_GET array.
All you have to do to accomplish this is do something like this:
$myvar = $_GET['ws-id'];
Here is a good article to give you more information on this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.