To add a custom footer to the WordPress admin area, you can use the admin_footer_text
hook. This hook allows you to add custom content at the bottom of the admin pages.
Here’s an example code snippet that demonstrates how to add a custom footer to the WordPress admin area:
function wpsnippets_custom_admin_footer() {
echo '<span id="footer-thankyou">Custom footer text</span>';
}
add_filter('admin_footer_text', 'wpsnippets_custom_admin_footer');
In this code snippet, we define a custom function wpsnippets_custom_admin_footer
that echoes the desired footer text. Then, we use the add_filter
function to hook this custom function to the admin_footer_text
filter. This ensures that our custom footer text is displayed in the WordPress admin area.
You can modify the echo
statement within the wpsnippets_custom_admin_footer
function to display any custom content you want in the admin footer.
Examples
Example 1: Adding a Custom Footer to the WordPress Admin Area
This use case demonstrates how to add a custom footer to the WordPress admin area. By adding a custom footer, you can display additional information or branding to the admin users.
function wpsnippets_custom_admin_footer() {
echo 'This is a custom footer.';
}
add_filter( 'admin_footer_text', 'wpsnippets_custom_admin_footer' );
In this code example, we define a custom PHP function wpsnippets_custom_admin_footer()
that echoes the desired custom footer text. We then use the add_filter()
function to hook this custom function to the admin_footer_text
filter, which allows us to modify the default footer text in the WordPress admin area.
Example 2: Adding a Custom Footer with HTML Markup
This use case demonstrates how to add a custom footer with HTML markup to the WordPress admin area. By using HTML markup, you can add links, images, or other interactive elements to the custom footer.
function wpsnippets_custom_admin_footer() {
echo '<p>This is a custom footer with <a href="https://example.com">a link</a>.</p>';
}
add_filter( 'admin_footer_text', 'wpsnippets_custom_admin_footer' );
In this code example, we define a custom PHP function wpsnippets_custom_admin_footer()
that echoes the desired custom footer HTML markup. We then use the add_filter()
function to hook this custom function to the admin_footer_text
filter, allowing us to replace the default footer text with our custom HTML markup.
Example 3: Adding a Custom Footer with Dynamic Content
This use case demonstrates how to add a custom footer with dynamic content to the WordPress admin area. By using dynamic content, you can display information that changes based on certain conditions or variables.
function wpsnippets_custom_admin_footer() {
$current_user = wp_get_current_user();
echo 'Welcome, ' . $current_user->display_name . '! This is a custom footer.';
}
add_filter( 'admin_footer_text', 'wpsnippets_custom_admin_footer' );
In this code example, we define a custom PHP function wpsnippets_custom_admin_footer()
that retrieves the current user’s display name using the wp_get_current_user()
function and echoes a personalized welcome message along with the custom footer text. We then use the add_filter()
function to hook this custom function to the admin_footer_text
filter, allowing us to display the dynamic content in the WordPress admin area footer.