metinsaylan // rogue developer

Advanced adsense targeting for wordpress Pt.2

In the first part, Advanced adsense targeting for your post content Pt.1, I explained you how to wrap your post content with targeting tags automatically using wordpress filters. In the second part I will show you how to exclude certain parts of your posts from ad targeting. *** We are going to use <!-- google_ad_section_start(weight=ignore) --> tag to disable ad targeting in certain parts of your posts. As I said before this is easy but not handy. Let’s add a shortcode for this to our functions.php:

  1. Open functions.php file in your theme folder.
  2. Insert the following code: [php title=”functions.php”]function insert_ad_targeting_ignore_tag($atts, $content = null ){ return ‘<!– google_ad_section_start(weight=ignore) –>’ . do_shortcode($content) . ‘<!– google_ad_section_end –>’; }; add_shortcode(‘ignore’, ‘insert_ad_targeting_ignore_tag’); ```

  3. Save the file and upload it if needed.

Now you can wrap unimportant parts of your post using [[ignore]] & [[/ignore]] shortcode tags. This will be a lot easier ;)

Hope this helps you on your adsense optimization.

Search Advanced adsense targeting for wordpress Pt.2 on Google