The print_admin_styles WordPress PHP function prints the styles queue in the HTML head on admin pages.
Usage
To use the print_admin_styles function, simply call it:
print_admin_styles();
Parameters
There are no parameters for this function.
More information
See WordPress Developer Resources: print_admin_styles
Examples
Print Admin Styles on a Custom Admin Page
This example demonstrates how to use print_admin_styles to enqueue and print admin styles on a custom admin page.
function my_custom_admin_page() { wp_enqueue_style('my-admin-style', get_template_directory_uri() . '/css/admin.css', array(), '1.0.0'); print_admin_styles(); } add_action('admin_menu', 'my_custom_admin_page');
Conditionally Print Admin Styles
This example shows how to conditionally print admin styles only on a specific admin page.
function my_conditionally_print_styles() { $screen = get_current_screen(); if ($screen->id == 'my-custom-page') { print_admin_styles(); } } add_action('admin_head', 'my_conditionally_print_styles');
Print Admin Styles for Custom Post Types
This example prints admin styles only for custom post types.
function my_custom_post_type_styles() { $screen = get_current_screen(); if ($screen->post_type == 'my-custom-post-type') { print_admin_styles(); } } add_action('admin_head', 'my_custom_post_type_styles');
Print Additional Admin Styles
This example shows how to print additional admin styles after the default ones are printed.
function my_additional_admin_styles() { echo '<style> .custom-class { color: red; } </style>'; print_admin_styles(); } add_action('admin_head', 'my_additional_admin_styles');
Print Admin Styles on a Plugin Settings Page
This example demonstrates how to print admin styles on a plugin settings page.
function my_plugin_settings_page() { wp_enqueue_style('my-plugin-style', plugins_url('css/admin.css', __FILE__), array(), '1.0.0'); print_admin_styles(); } add_action('admin_menu', 'my_plugin_settings_page');