Home » Ask (Forum) » Display Ads Only From Search Engine Visitors

Question

Hello Wp lovers, in this WordPress tutorial I will show to you How to Display Ads Only From Search Engine Visitors in your Wp site.

/* Display Ads Only to Search Engine Visitors */
function bw_fromsearchengine(){
	$ref = $_SERVER['HTTP_REFERER'];
	$SE = array( 'SE_name.com', '.google.', '.ask.', '.bing.', '.yahoo.', '.duckduckgo.', '.yandex.' );
	foreach ($SE as $source) {
		if (strpos($ref, $source)!==false) return true;
	}
	return false;
}

Now add this code into your theme for display your ad from visitor that come from SE (Search Engine).

/* show in your theme */
<?php if (function_exists('bw_fromsearchengine')) { if (bw_fromsearchengine()) { ?>
Ads
<?php }else{ ?>
Not Ads
<?php }} ?>

Good luck 🙂

Jul 18, 2016 (5 months ago) - Posted by 1 Comment

One Answer

  1. Support says:

    Thanks for the tutorial.

    Team Support

Your Answer

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