Skip Navigation

[Gelöst] Custom Datepicker icon not displaying in correct size

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 3 Jahre, 10 Monate. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luigi Bella vor 3 Jahre, 10 Monate.

Assistiert von: Christian Cox.

Author
Artikel
#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.
versteckter Link

The frontend works just fine, here is a page where you can see it: versteckter 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.

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.