Genesis 2.6 comes with a new AdSense Auto Ads feature to easily place relevant ads automatically based on Google’s machine learning algorithms in optimum locations.
As fancy as that sounds, many of us probably will not need this feature and would like to remove the corresponding meta box in Genesis theme settings and other places like the Customizer.
Update on March 08, 2018: Gary Jones has made available a plugin version of the same here. To install, you need to download the zip file and upload it via the Plugins screen.
Thanks to Gary Jones, all we need to disable auto ads feature in Genesis is to add this code in child theme’s functions.php:
// Sets AdSense ID to always be an empty string - stops meta box from appearing on Post screens.
add_filter( 'genesis_pre_get_option_adsense_id', '__return_empty_string' );
// Removes AdSense metabox from Theme Settings.
add_action( 'genesis_theme_settings_metaboxes', function () {
remove_meta_box( 'genesis-theme-settings-adsense', 'toplevel_page_genesis', 'main' );
});
// Removes AdSense ID setting from Customizer.
add_filter( 'genesis_customizer_theme_settings_config', function ( $config ) {
unset( $config['genesis']['sections']['genesis_adsense'] );
return $config;
});
Source: https://github.com/copyblogger/genesis/pull/1819#issuecomment-366076966
Thanks for sharing. It boggles the mind that StudioPress would add something that clearly should not be part of a theme into Genesis.
Wow. If I don’t use this hack and already have google ads (not auto ads) on my pages – will this new 2.6 feature affect me in any way?
No. You are good. They will continue to work as before.
Just don’t put in your publisher ID in the new auto ads settings or if you want to get rid of these entry points (meta box, Customizer option etc.), add the code in the tutorial.
Thanks for writing this up so quickly, Sridhar. I’ll need to use it on most client sites.
Here’s a plugin that uses the above code: https://github.com/GaryJones/genesis-disable-adsense-auto-ads
Thanks Gary. Updated the post with a link to your plugin.