I've been searching for a few hours now but I can't seem to find a solution to this.

I'm developing a plugin and I'd like to be able to add custom text underneath the admin media library heading. I thought there might be some hook to do this.

Can't seem to find anything that shows how you can add text to the admin screen at all. How would I go about doing this?


enter image description here

  • Have you looked at the source code to see if there's an action or filter hook called at this point? – Andy Macaulay-Brook Jul 23 '16 at 14:30

That area of all admin screens is where admin notices are displayed, so you could generate an admin notice.

Here's a suitable function and hook:

function wpse_233031_admin_notice() {
    <div class="notice notice-info">
        <p>Your message here!</p>

function wpse_233031_hook_admin_notice() {
    add_action( 'admin_notices', 'wpse_233031_admin_notice' );

add_action( 'load-upload.php', 'wpse_233031_hook_admin_notice' );

/* Edited out anonymous function callback, 
   which not only requires PHP 5.3 but is poor WP practice as
   it prevents removal of the function from the hook

Every admin page fires a unique hook of the form load-{unique-string-for-this-screen}. For top level admin pages it takes the form load-{filename}. On the load-upload.php hook we hook into admin_notices so that your notice only appears on this screen.

You should add a class of notice to your div and one of notice-error, notice-warning, notice-success, or notice-info to get the standard WP styling. (If you add a class of is-dismissible WP will supply you with a closing icon, but I believe you need to do the heavy lifting of dismissal and storing dismissed state yourself.)

  • Recommended not to use anonymous functions as it's not possible to remove that action if that is anonymous function. – bravokeyl Jul 23 '16 at 17:59
  • @bravokeyl That's a point. – Andy Macaulay-Brook Jul 23 '16 at 18:01
  • 1
    @bravokeyl Edited to fix that. – Andy Macaulay-Brook Jul 23 '16 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.