I found this great php code that will help me serve adsense ads only to search traffic.
I need help coding it so that if the user is not coming from search then another ad code is shown to the user.
This is the original code
<?php if (function_exists(‘from_searchengine’)) {
if (from_searchengine()) { ?>
INSERT YOUR ADSENSE/BANNER CODE HERE
<?php } } ?>
What I am looking to do is if the user is not from search show another banner code.
Can someone help me with editing the code?
I don't think it's the best practise what you're doing but still:
<?php if (function_exists(‘from_searchengine’)) {
if (from_searchengine()) { ?>
INSERT YOUR ADSENSE/BANNER CODE HERE
<?php } else { ?>
INSERT ANOTHER AD CODE HERE
<?php } } ?>
but it looks better when you do that:
<?php
$ad_code = "INSERT YOUR ADSENSE/BANNER CODE HERE";
$another_ad_code = "INSERT ANOTHER AD CODE HERE";
if (function_exists(‘from_searchengine’)) {
if (from_searchengine()) {
echo $ad_code;
}else{
// if not from search engine
echo $another_ad_code;
}
} else{
// if function doesn't exist
echo $another_ad_code;
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.