Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Dynamic logo/banner depending on affiliate link

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_valuewe 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;
}

Related Posts:

  1. Change homepage’s logo link [duplicate]
  2. Get parent page url to show up when it is in child pages
  3. Why is there a link tag with rel “profile” pointing to gmpg.org?
  4. How to use wpLink without editor?
  5. Add CSS Class to Link in TinyMCE editor
  6. How to print translation supported text with HTML URL
  7. Get the prev / next page links only (not title, etc)
  8. How to re-enable the links manager?
  9. Wondering how to turn your firefox bookmarks into a WordPress blog?
  10. How can I link to the most recent post in a category?
  11. Links redirecting to localhost after migration to server
  12. Is it possible to link to draft pages?
  13. How can I find all internal links that are pointing to post/page?
  14. Change logo url link
  15. Creating a Link Directory using WordPress?
  16. Count and show Clicks on external links in a single page/post
  17. How to use wp_rel_nofollow to add nofollow to external links only?
  18. get_category_link() is returning nothing
  19. Is there any way to set default for “Insert/Edit Link” to “Open link in new window”?
  20. root-relative links for multiple parked domains
  21. Get link value only from the_content()?
  22. How to splice in wp_links links into the loop?
  23. widget to output a link to archive view
  24. Is there an easy way to create a links index page?
  25. Can’t add a class to links in the visual editor since WP 3.1?
  26. What is the canonical way to link to pages?
  27. how can i add a menu link that goes to an external page
  28. Remove all links to a specific website
  29. HTTPS page link in menu
  30. How do I remove or disable “Or link to existing content” in “insert link” dialogue?
  31. Retrieving all Links from a Post?
  32. Link Category Description
  33. Auto-embed link info from URLs in link post format?
  34. programatically change href to onclick=window.open
  35. Disable automatic content hyperlinking
  36. Open link in a new tab checked by default when adding a new link in visual post editor
  37. Deep linking to an accordion tab with Visual Composer
  38. Setting a page link in the footer?
  39. How to add/change a value of $wpdb property/var?
  40. Need advice on how to add links in users profile page?
  41. Generate Random Post Links Somewhere in the post
  42. How to hide a customization link themes menu in wordpress?
  43. Getting only the most recent bookmark?
  44. WordPress links/bookmarks – need to urlencode because spaces are getting stripped
  45. Custom Post Type archive link in WYSIWYG editor
  46. Add Link Text Back to Insert/edit link Box
  47. How to list all external URLs that I have posted on my WordPress blog?
  48. How do I make my navigation bar link to an external page?
  49. Plugin that inserts favicon next to links
  50. Create anchor from Wysiwyg editor
  51. Is there any way of changing the post order via user click?
  52. Get post / page ID from ACF Link field
  53. Creating a navigation link to my front-page
  54. How to remove author name and link from a shared link preview?
  55. wp_get_attachment_link to add title attribute to link tag around image
  56. Can I generate then display a mixed list of linked and unlinked terms
  57. Relative links for performance?
  58. Make page tab link to pdf
  59. Dont’t change active Button while I’m listing a category?
  60. How to change server name on WordPress Installation?
  61. How to prevent a page from being linked in the menu/crossbar
  62. How do i set the read more link?
  63. Plugin for wikipedia style references in WP?
  64. Problem creating an edit link for a custom post type
  65. How to convert all links to no follow links of particlular section of a webpage
  66. Linking from Menu and a Page to the latest post from a specific category
  67. After duplicating site to a sub folder, links send user to original site
  68. Automaticly replace a link with other “new link”
  69. Links are not working on All Plugins Page
  70. How to add a WordPress page with multiple picture links?
  71. Enumerating over a category of links
  72. Is there a way to hide WordPress behind a web visible directory?
  73. Twitter links in widget don’t work?
  74. Links in nonalphabetic order
  75. Copy button for anchor link
  76. How to automatically nofollow a set domains? (I seem to have half of the answer)
  77. WordPress links https overwrite issue
  78. My custom link works only on home page
  79. Read more link to external webpage
  80. plugin admin subpage title and links in menu not highlited at current page
  81. Change Read More in Child theme
  82. Add text excerpt and pictures to hyperlinks?
  83. Default Link for TinyMCE “Add Link”
  84. WordPress changes URL?
  85. How to apply default post categories to link manager plugin
  86. Parent/child pages and link structure the right way
  87. How do I get link URLs from the WordPress links backend into an array?
  88. Link below the footer removal
  89. How to change all external links to “nofollow” but only for Contributor role?
  90. Is there anyway to use relative link instead of absolute link?
  91. How to link to local post
  92. How can I show different image links for different languages with qTranslate?
  93. How do I hide the ‘Edit’ link in publshed posts
  94. Exclude uploaded files from appearing in the excerpt()
  95. link to single most recent post, regardless of category
  96. Change description of my Jetpack facebook shared links [closed]
  97. Do you use links?
  98. WP Method `get_theme_file_uri()` Doesn’t Seem To Be Working Properly When Used In The Head Section Of A Site
  99. Add the title attribute to links
  100. Moving a wordpress.org website to another domain name?
Categories links Tags links, logo, woocommerce-offtopic
How to get the slug of the homepage when editing it in WP admin?
WordPress Frontend Post Form (Bootstrap Modal) Not Creating Post

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress