0

i'm building a plugin and i want my enqueue style on all my pages not only the slug (toplevel

    function load_custom_wp_admin_style($hook) {
        if($hook != 'toplevel_page_myplugin') {
                return;
        }
        wp_enqueue_style( 'custom_wp_admin_css', plugins_url('css/style.css', __FILE__) );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

This only gives me my style at the page admin.php?page=myplugin but i got more pages like admin.php?page=sieronline-page1 admin.php?page=myplugin-page2.

How can i do this?

Thanks a lot.

2

If you want enqueue style on all admin pages You can use the following code

    function load_custom_wp_admin_style() {
        wp_enqueue_style( 'custom_wp_admin_css', plugins_url('css/style.css', __FILE__) );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

Or if you want enqueue style on specific pages, You can use the following code

function load_custom_wp_admin_style($hook) {
        if($hook != 'toplevel_page_myplugin' || $hook != 'widgets.php' || $hook != 'edit.php') {
                return;
        }
        wp_enqueue_style( 'custom_wp_admin_css', plugins_url('css/style.css', __FILE__) );
}
    add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.