How do make your Adsense targeting for your post content in WordPress-Part 01?

  • Sharebar

Adsense is a great way making money from your blog. It also allows content targeting for ad units. Here i will give you a little trick you can use on your wordpress blog to target your ads using your post content. You can easily target your ads putting your content inside <!-- google_ad_section_start --> and <!-- google_ad_section_end --> tags. This is simple but not handy. Let’s automate it for all our wordpress blog posts using a simple content filter. Here we go..

1. Open your functions.php file in your theme folder.
2. Insert this code:

function insert_ad_targeting($content) {
    $content = "<!-- google_ad_section_start -->".$content."<!-- google_ad_section_end -->"; // Wrap the content with targeting tags
    return $content; // Return it
add_filter('the_content', 'insert_ad_targeting');

3. Save your file & upload it to your server. And you are done.

Now all your pages & posts will be wrapped for ad targeting generating relative ads only for your post contents.



You can leave a response, or trackback from your own site.