Skip to content


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:
    [code='php']function mightyadsense_generateads($content)[/code]
    This function starts with the code to insert the ads into a single post: [code='php']if (is_single())[/code]. So, again we’re looking around line 385:
    [code='php']//reach the right assignment.
    $adsstr=getAds($p,$content);
    //exit the loop
    $p=1000;
    $mai=1000;[/code]
    This is what actually ads the ad code. Around the above code we add the following:
    [code='php']
    if (!in_category(9)) // PayPerPost Hack
    {
    $adsstr=getAds($p,$content);
    //exit the loop
    $p=1000;
    $mai=1000;
    }[/code]
    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.

Posted in Blog, Money, PHP.

Related Posts

  • None Found

8 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. azwanhadzree says

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

  2. Baz L says

    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. yosax says

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

  4. Anna Leah says

    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. Cathryn says

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

  6. blog deraibali says

    How do I show more than 3 adsense with MightyAdsense?

  7. Harold Newman says

    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. Karen Hayes says

    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



Some HTML is OK

or, reply to this post via trackback.

CommentLuv Enabled