PHP in Ad Codes

Posted in: Newspaper
Post count: 4

Hi there,

Wanted to know if it was possible to use <php> in the ad code fields. I want to restrict ads to only display if a visitor comes from a search engine. I’m using this in the functions.php file:

function agentwp_adsforSEvisitors(){
$ref = $_SERVER['HTTP_REFERER'];
$SEs = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
foreach ($SEs as $source) {
if (strpos($ref,$source)!==false) return true;
}
return false;
}

And I want to use this surrounding my Google AdSense code:

if (function_exists('agentwp_adsforSEvisitors')) {
if (agentwp_adsforSEvisitors()) {
//INSERT YOUR AD CODE HERE
}
}

Any help with this, or another solution that would accomplish the same thing would be great.

Thanks!

Jason

Post count: 6600

Hi,

Try adding the code directly in file, where you want the ad to be displayed for example if you want on header edit here: http://screencast.com/t/lGs4ZXrR5

Hope this help!
Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.