Support » Plugins » Easy way to remove multiple hard-coded Adsense ads from articles?

  • Hi everyone, sorry if this has been posted before (and if I’m posting in the wrong area) but I couldn’t find anything in my search.

    I use Google DFP Small Business to serve ads from a variety of networks, using Google Adsense to sell the remainder. These are all in the header and sidebar. However, I also have a Google Adsense 300×250 unit appearing in some of my articles, e.g. at the bottom below the content and above the comments.

    This code was pasted in directly to the post editor, and is not controlled through a plugin or hard-coded into the site’s backend. The code hasn’t been pasted into every post, but nevertheless quite a few of the archives articles. An example is here (see bottom of article):

    This was done when I was very new to WordPress/blogging, and didn’t know there were plugins available to control this sort of thing. Stupid I know, but we live and learn!

    I have now installed Easy Adsense to manage an ad at the bottom of every post, and to test out various formats to see what works best. But I can’t activate it until I’ve removed the ads that currently appear in certain articles, as I might be in breach of Google’s terms and conditions when an additional ad appears (some articles have more than one Adsense ad pasted in, and I know Google allows three max).

    Sorry to be long winded! My question is: is there an easy way (plugin or hack) to disable the Adsense code that’s currently hard-coded into some of my archives articles, so that I can then go and activate Easy Adsense? Or am I going to have to trawl through each post and manually remove the ad code where it appears?

    Thanks massively in advance for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • you could export your database via phpmyadmin or whatever and do a search and replace in a text editor(sublimetext2 !!), just make sure you keep a backup of the untouched database then search for the block of code (assuming it’s the same in every post) and replace it with nothing. Then import it and your posts should be adsense free!

    You could instead add a function to your theme to scan the post for the code and remove it as your pages are generated.

    I’d use the first option.

    Thanks blackpenpress, that’s really helpful and very much appreciate your advice. Sounds pretty technical – definitely not my strong point! – but I’ll get reading and I have someone who can help me if needs be.



    It’s pretty easy to do the find and replace on the exported database, just keep backups!! In more detail..

    log into phpmyadmin
    click on your wordpress database
    click export and download as whatever.sql
    open save a copy (or two) of the file
    open in sublimetext2
    find and replace – in the find box paste the adsense code exactly, no spaces either side
    leave the replace field completely empty – click replace all (or similar)
    save the updated file
    in phpmyadmin import the updated file to your database or even better create a new database and import to that, then you can just update wp-config.php to switch between them laving your existing database untouched

    Fantastic stuff, that’s absolutely brilliant! Thanks massively and I’ll let you know how I get on 🙂

    no problem 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Easy way to remove multiple hard-coded Adsense ads from articles?’ is closed to new replies.