I’m writing a plugin which would print a notice, but only on the media page. I found the admin_notices and all_admin_notices actions, but these are fired on all admin pages. Is there any way to find which admin page is the hook being called on from within the callback?

2 Answers
2

There is a global variable called $pagenow for the use within WP Admin:

global $pagenow;
if ( $pagenow == 'upload.php' ) :

    function custom_admin_notice() {
        echo '<div class="updated"><p>Updated!</p></div>';
    }
    add_action( 'admin_notices', 'custom_admin_notice' );

endif;

UPDATE: Simply include the snippet in your themes or plugins functions.php

Leave a Reply

Your email address will not be published. Required fields are marked *