The solution for this is, in my opinion, divided into two steps.
The first step is to set the variable, which defines the affiliate, that sends you the visitor.
The second step is to display an appropriate logo based on the value of the first variable.
The solution for the first step would probably look somewhat like this:
if( isset($_GET['affiliate']) ){
$affiliate_value = $_REQUEST['affiliate'];
setcookie('affiliate', $affiliate_value, time()+3600);
} elseif( isset($_COOKIE['affiliate']) ){
$affiliate_value = $_COOKIE['affiliate'];
} else {
$affiliate_value = NULL;
}
This would probably go somewhere into the functions.php
. What this does is to look into the url query string (for the purpose of demonstration the query variable is called “affiliate”) and if a value is there we assign a variable and save that value in a cookie.
If no query string is there we look for a cookie. If nothing is there the value is NULL.
Then, after you have defined your $affiliate_value
we can build a switch in the header.php
to display the correct logo. It should look somewhat like this:
switch($affiliate_value) {
case("affiliate_one"):
echo '<img src="https://wordpress.stackexchange.com/questions/152056/url_to_logo_one" >';
break;
case("affiliate_two"):
echo '<img src="url_to_logo_two" >';
break;
case("affiliate_three"):
echo '<img src="url_to_logo_three" >';
break;
default:
echo '<img src="url_to_default_logo" >';
break;
}