How To Make PayPerPost and Google Adsense Play Nice – MightyAdsense Plugin Hack

MightyAdsense – Automatically Inject Ads

The MightyAdsense Plugin has many useful options. You can store up to 10 different sets of ads for various locations on your blog. You can insert them into your template by calling one simple function instead of having to paste entire code snippets for the ads. Since all your code for the ads are stored in WordPress, it makes changing the format of an ad a breeze.

But here’s where the magic comes in. You can chose certain ads to be automatically inserted into posts and pages. One your homepage, category list, etc; where you list many different posts on one page, you can chose to insert specific ads into certain ads on the page. Namely the first, second, and third posts. This is the set up I have for my first post:

ad_post_1.png

The second post I leave blank, but have the following on the third:
ad_post_3.png

Now this is what I have on every page/post:ad_post.png

PayPerPost Says No Ads

PayPerPost has recently modified their Terms of Service:

Inline Ads and Links. There are to be no third party links, ads or other detractors located within the sponsored post.

Now this has seriously thrown a kink into my normal blogging activity. I guess I could change the tight of ad or change the placement of the ad. But over time I’ve come to realize that this in post block ad is the highest paying ad on my site. It makes sense, since the ad is directly related to the post it is in. MightyAdsense currently has no option to manually exclude certain posts from having ads. So it’s all or nothing, Google Adsense or PayPerPost. Why can’t we have the best of both worlds? Well now you can!

Solution: MightyAdsense Hack – Automatically Exclude Certain Categories

Now, as you can tell, I’m a big fan of the whole automatic thing, but it does take a little bit homework.

  1. Ensure that all PayPerPost posts are in a particular category.
    My posts are always in the category: Sponsored Posts.
  2. Find the Category ID
    Go to the Manage menu in your WordPress administrator menu, click Categories, then find the ID in the, um…well, ID column.
  3. Administer the MightyAdsense Hack
    Open up the MightyAdsense plugin in a text editor. We’re looking in the area of line 373 (ver. 4.1. Yours might vary) for the following function:
    function mightyadsense_generateads($content)

    This function starts with the code to insert the ads into a single post:

    if (is_single())

    . So, again we’re looking around line 385:

    //reach the right assignment.
    $adsstr=getAds($p,$content);
    //exit the loop
    $p=1000;
    $mai=1000;

    This is what actually ads the ad code. Around the above code we add the following:

    if (!in_category(9))    // PayPerPost Hack
    {
    $adsstr=getAds($p,$content);
    //exit the loop
    $p=1000;
    $mai=1000;
    }

    Now, I think you can follow me here. My Sponsored Post category id is 9. So we’re saying “insert this ad everywhere except in posts with category ID 9”.

Now obviously, there are some disadvantages to this. You need to edit the code for each different blog you own. What would be ideal is if you could add some option to the plugin where you user could select the category they wish to exclude. But, I’m not a WordPress plugin creator and I did this on my lunch hour.

This way we keep ads out of certain posts and keep PayPerPost happy and still have ads in the rest of our posts. I hope this helps the masses out there.

Comments

  1. hi there! thanks for droping by and for the tips.

  2. No problem man. I sat there thinking there must be some way to get around this. I just wish I could make it better by enabling you to add categories in the administrator’s page, but again: I’m not too clear with the whole WordPress thing.

  3. Wonderful…
    I’ve implement this code at my site.

  4. Adsense is the best paying make money online program on the internet. I just wish that i could increase my website traffic to high levels so that i could earn more money on Adsense.
    .

  5. i use Adsense on my blogs and websites, i can say that Adsense is the best make money online program on the internet.

  6. How do I show more than 3 adsense with MightyAdsense?

  7. i am really very thankful that Google launched the Adsense program. this enables most of us who owns several websites to work at home.

  8. i love google Adsense, it enables me to earn money on the websites and forums that i have put up several years ago. if you got tons of websites, you can earn a lot from Adsense alone

  9. It would be kind of stressful having to edit the plug-in after each update thus on my site I created different single.php for different categories/posts. That way I can show ads on some posts and not show on others.

    Since most adsense plug-ins don’t work with cache plug-ins, I’m placing adsense codes directly into the single post template.

    Hope this article helps you guys: http://www.wpfunc.com/wordpress/use-two-or-more-single-php.html.

    Cheers
    .-= Udegbunam Chukwudi´s last blog ..Quick Update- Making Blogs Faster With W3 Total Cache =-.