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?

1 Answers

2
Matthew Vanlandingham On

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