Using WordPress ‘admin_footer-{$GLOBALS[‘hook_suffix’]}’ PHP action

The admin_footer-{$GLOBALS[‘hook_suffix’]} WordPress PHP action is used to print scripts or data after the default footer scripts on a specific admin page.

Usage

add_action('admin_footer-' . $GLOBALS['hook_suffix'], 'your_custom_function');
function your_custom_function() {
    // Your custom code here
}

Parameters

  • $hook_suffix (string) – The current admin page hook suffix.

More information

See WordPress Developer Resources: admin_footer-{$GLOBALS[‘hook_suffix’]}

Examples

This example adds a custom script to the footer of the Plugins page in the WordPress admin.

add_action('admin_footer-plugins.php', 'add_custom_script_to_plugins_page');
function add_custom_script_to_plugins_page() {
    // Output custom JavaScript for the Plugins page
    echo "<script>alert('Welcome to the Plugins page!');</script>";
}

This example adds custom CSS to the footer of the Dashboard page in the WordPress admin.

add_action('admin_footer-index.php', 'add_custom_css_to_dashboard');
function add_custom_css_to_dashboard() {
    // Output custom CSS for the Dashboard
    echo "<style>body { background-color: lightblue; }</style>";
}

This example adds a custom message to the footer of the Posts page in the WordPress admin.

add_action('admin_footer-edit.php', 'add_custom_message_to_posts_page');
function add_custom_message_to_posts_page() {
    // Output custom message for the Posts page
    echo "<p>Don't forget to regularly update your posts!</p>";
}

Load a custom script only on the Media Library page

This example loads a custom JavaScript file on the Media Library page in the WordPress admin.

add_action('admin_footer-upload.php', 'load_custom_script_on_media_library');
function load_custom_script_on_media_library() {
    // Load custom JavaScript for the Media Library page
    wp_enqueue_script('my_custom_script', 'path/to/your/custom/script.js', array(), '1.0.0', true);
}

This example adds custom functionality to the footer of the Categories page in the WordPress admin.

add_action('admin_footer-edit-tags.php', 'add_custom_functionality_to_categories_page');
function add_custom_functionality_to_categories_page() {
    // Your custom code for the Categories page
    echo "<script>console.log('Categories page loaded.');</script>";
}

Add a custom JavaScript alert to the Plugins page

This code snippet adds a JavaScript alert to the Plugins page in the admin area.

add_action('admin_footer-plugins.php', 'custom_alert_plugins_page');
function custom_alert_plugins_page() {
    echo '<script>alert("Hello from the Plugins page!");</script>';
}

Add custom CSS to the Dashboard

This example adds custom CSS to the Dashboard page in the admin area.

add_action('admin_footer-index.php', 'add_custom_css_dashboard');
function add_custom_css_dashboard() {
    echo '<style>.welcome-panel { background-color: lightblue; }</style>';
}

Add a custom JavaScript console log to the Posts page

This code snippet adds a custom JavaScript console log message to the Posts page in the admin area.

add_action('admin_footer-edit.php', 'custom_console_log_posts_page');
function custom_console_log_posts_page() {
    echo '<script>console.log("Hello from the Posts page!");</script>';
}

Add custom JavaScript to the Media Library page

This example adds custom JavaScript code to the Media Library page in the admin area.

add_action('admin_footer-upload.php', 'custom_js_media_library');
function custom_js_media_library() {
    echo '<script>console.log("Hello from the Media Library page!");</script>';
}

Add custom HTML to the Themes page

This code snippet adds custom HTML to the Themes page in the admin area.

add_action('admin_footer-themes.php', 'custom_html_themes_page');
function custom_html_themes_page() {
    echo '<div style="position: fixed; bottom: 10px; right: 10px; background-color: white; padding: 10px; border: 1px solid black;">Custom HTML on Themes page</div>';
}

Add a custom JavaScript to the personal options

This example adds custom JavaScript to the personal options section.

add_action('admin_footer-profile.php', 'add_custom_js');
function add_custom_js() {
    echo '<script>
        // Your custom JavaScript here
    </script>';
}