If you previously added AdSense code to your WordPress blog but don’t remember where you placed it, don’t worry! There are multiple places where the code might be hiding. In this guide, I’ll walk you through different methods to find and remove your old AdSense code so you can replace it with your new AdSense account.
Step 1: Check the Theme File Editor for Hardcoded AdSense Code
If you manually added AdSense code to your theme files, follow these steps to find and remove it:
1. Open the Theme File Editor
- Log in to your WordPress Dashboard.
- Go to Appearance > Theme File Editor.
2. Check Common Files for AdSense Code
Look for AdSense code (<script>
, adsbygoogle
, or google_ad_client
) inside these files:
- header.php (Usually inside
<head>
) - footer.php (At the bottom, before
</body>
) - single.php (If you added ads to blog posts)
- sidebar.php (If ads were in the sidebar)
- functions.php (Check if you used
add_action
to insert ads)
3. Remove the AdSense Code
Once you find the AdSense code, delete it and click Update File.
Step 2: Check the Widget Section
If you used a widget to place AdSense ads, follow these steps:
- Go to Appearance > Widgets.
- Look for Custom HTML, Text, or AdSense widgets.
- Click on the widget and check if it contains any AdSense script.
- Remove the code and click Save Changes.
Step 3: Check the Theme Customizer
Some themes allow adding scripts via the WordPress Customizer:
- Go to Appearance > Customize.
- Check Additional CSS or Custom Scripts.
- If you find AdSense code, remove it and click Publish.
Step 4: Check Plugin Settings
You might have used an AdSense plugin to insert ads.
- Go to Plugins > Installed Plugins.
- Look for plugins like Ad Inserter, Advanced Ads, WP Simple AdSense Insertion.
- If you find one, open its settings and check for any AdSense code.
- Remove or replace it with the new AdSense code.
Step 5: Check the Database (For Advanced Users)
If you added AdSense directly to your posts or pages, you can find and remove it from the database.
- Go to phpMyAdmin in your hosting control panel.
- Select your WordPress database.
- Click on the wp_posts table.
- Use the Search feature to look for
adsbygoogle
or your old AdSense publisher ID. - If you find it inside any post content, edit and remove it.
⚠️ Warning: Always back up your database before making changes!
Step 6: Check Third-Party Code Injection Tools
If you used a third-party tool to insert ads, check:
- Site Kit by Google (Go to Site Kit settings)
- Header and Footer Scripts Plugin (Check settings under “Settings > Insert Headers and Footers”)
Remove any old AdSense code from these tools.
Final Step: Clear Cache and Test Your Site
After removing the AdSense code:
- Clear your WordPress cache (if using a caching plugin like WP Rocket or W3 Total Cache).
- Check your website’s source code (Right-click > View Page Source, then search for “adsbygoogle”).
- Test your site to ensure old ads are gone.
Conclusion
By following these steps, you can successfully remove all traces of your old AdSense code and replace it with your new one. If you’re still seeing old ads, try waiting a few hours, as changes may take time to reflect.

Dinesh K Verma is an experienced SEO strategist and WordPress expert with over 12 years of industry experience. He specializes in creating optimized, user-friendly websites that drive traffic and conversions. As the founder of SEOBallia.com, Dinesh shares his expertise through insightful articles and practical guides. His mission is to empower businesses and individuals to achieve online success.