Skip to content

Instantly share code, notes, and snippets.

@zytzagoo
Last active September 19, 2023 18:14
Show Gist options
  • Save zytzagoo/05743e970a3a717d23d7 to your computer and use it in GitHub Desktop.
Save zytzagoo/05743e970a3a717d23d7 to your computer and use it in GitHub Desktop.
Disable annoying Yoast SEO admin notifications
<?php
add_action( 'admin_init', function() {
if ( class_exists( 'Yoast_Notification_Center' ) ) {
$yoast_nc = Yoast_Notification_Center::get();
remove_action( 'admin_notices', array( $yoast_nc, 'display_notifications' ) );
remove_action( 'all_admin_notices', array( $yoast_nc, 'display_notifications' ) );
}
});
@theking2
Copy link

theking2 commented Mar 24, 2023

Make sure to code this as follows:

add_action( 'admin_init', "remove_yoast_notifications");
function remove_yoast_notifications() {
    if ( class_exists( 'Yoast_Notification_Center' ) ) {
        $yoast_nc = Yoast_Notification_Center::get();
        remove_action( 'admin_notices', array( $yoast_nc, 'display_notifications' ) );
        remove_action( 'all_admin_notices', array( $yoast_nc, 'display_notifications' ) );
    }
}

As a child theme might want to put them back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment