Skip Navigation

[Resolved] Custom Datepicker icon not displaying in correct size

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use a custom icon for the datepicker, but the styles I added in Additional CSS are not applied in admin so the icon is always too large.

Solution: Use a separate stylesheet for admin styles and enqueue it with the admin_enqueue_scripts hook, or enqueue your styles directly in admin head with the admin_head hook.

Relevant Documentation:
https://codex.wordpress.org/Plugin_API/Action_Reference/admin_head

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.49 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Luigi Bella 3 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1707159

I have replaced the datepicker icon using a method mentioned in a different thread using the functions.php file, but even with CSS I cannot get the new icon to display in the correct size on the backend.
hidden link

The frontend works just fine, here is a page where you can see it: hidden link

However, adding the following CSS is not affecting the size on the backend:
img.ui-datepicker-trigger {
max-width: 20px !important;
}

#1707269

Hi, if you want to load custom CSS in the back-end of the site, you must enqueue it in your theme separately from the front-end CSS. I don't think Additional CSS in the theme customizer is loaded in the back-end, only in the front-end. Here's some example code I use in a child theme to load a custom stylesheet in admin:

function tssupp_load_custom_wp_admin_style() {
        wp_register_style( 'tssupp_custom_wp_admin_css', get_stylesheet_directory_uri() . '/admin-style.css', false, '1.0.0' );
        wp_enqueue_style( 'tssupp_custom_wp_admin_css' );
}
add_action( 'admin_enqueue_scripts', 'tssupp_load_custom_wp_admin_style' );

This code loads the stylesheet admin-style.css, from my child theme directory, in wp-admin. Just an example, you can customize it to fit your needs according to the documentation here: https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
You can add a parameter $hook_suffix to the callback to get information about the current admin page, so the stylesheet only loads where you might need it.

#1707271

Thank you, Christian! This got me pointed in the right direction and a simple Google search helped me put together the following:

add_action('admin_head', 'calendar_icon_size');

function calendar_icon_size() {
echo '<style>
img.ui-datepicker-trigger {
max-width: 20px !important;
}
</style>';
}

The issue is now resolved.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.