This is the second tutorial in the series showing how I did the things that the girl from Google told me on our consultation session.
In this tutorial, you will learn how to add an inline adsense block to your post content just like it does on the posts on comluv.com
[youtube]http://www.youtube.com/watch?v=woVcLdIvfeI[/youtube]
To see the subtitles, start playing the video, click the arrow on the video toolbar and then click the red CC
Here is the code that was used in the video
add_filter('the_content', 'my_inline_adsense'); function my_inline_adsense($content){ if(is_singular()){ $firstendh2 = stripos($content,'</h2>'); $firstendh2 += 5; $secondendh2 = stripos($content,'</h2>',$firstendh2); $secondendh2 += 5; $startpost = substr($content,0,$secondendh2);$endpost = substr($content,$secondendh2); $divstart = '<div style="margin-right: 5px; margin-bottom: 5px; float: left;">'; $divend = '</div>'; $adsense = '<script type="text/javascript"><!-- google_ad_client = "ca-pub-4655222703200811"; /* inline with post */ google_ad_slot = "2605694935"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>'; $content = $startpost . $divstart . $adsense . $divend . $endpost; } return $content; }
If you have any questions or feedback, feel free to leave them in the comments.