How to disable AdSense Auto Ads in Genesis

Posted on
5/5 - (199 votes)

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