Insert custom PHP head above in WP pages

I’ve made a WordPress site. Before, I had a coded site in HTML. My new WordPress site is still in maintenance mode. But, I want to insert a PHP code above all the website content. This is my code:

<?php
//DETECT REFERRER
if(empty($_SESSION[“referrer”]))
{
$referrer = $_SERVER[“HTTP_REFERER”];
if(empty($referrer))
$referrer = $_SERVER[“SCRIPT_URI”].((!empty($_SERVER[“QUERY_STRING”]))? ‘?’.$_SERVER[“QUERY_STRING”]:”);
$_SESSION[“referrer”] = $referrer;
}
//DETECT AFFILIATE ID
if(empty($_SESSION[“aid”]))
{
$aid = $_GET[“aid”];
if(empty($aid))
$aid = $_COOKIE[“aid”];
if(empty($aid))
$aid = 1;
setcookie(“aid”, $aid, strtotime(“+10 years”), “/”);
$_SESSION[“aid”] = $aid;
}
?>

But I don’t know how to insert it in avery page on my site. Is there any way to do this? If that’s not possible, is there a different way to get a cookie when a query string is in the URL? Thanks in advance.

Regards, Luuk Faasse

Read more here:: <a href=https://wordpress.stackexchange.com/questions/296561/insert-custom-php-head-above-html-in-wp-pages target="_blank" title="Insert custom PHP head above in WP pages” rel=nofollow>Insert custom PHP head above in WP pages

Leave a Reply

Your email address will not be published. Required fields are marked *