Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 95894

komanderkin on "[Theme: Genesis] Adding adsense code to more tag?"

$
0
0

hi everyone!

i was able to insert adsense code with the <!--more--> tag on my old WordPress site (K2 theme) using the following code (added to functions.php):

function adsense_added_at_more_tag($text) {
if( is_single() ) :
$ads_text = 'BANNER GOES HERE';
$pos1 = strpos($text, '<span id="more-');
$pos2 = strpos($text, '</span>', $pos1);
$text1 = substr($text, 0, $pos2);
$text2 = substr($text, $pos2);
$text = $text1 . $ads_text . $text2;
endif;
return $text;
}

The adsense banner appeared on the place where the <!--more--> tag was inserted in the post.

Any ideas on how to get this to work in Genesis theme?


Viewing all articles
Browse latest Browse all 95894

Trending Articles