Is it possible to load the css just on my plugin admin page?

admin2025-06-05  2

I am trying to build a wp plugin using vuejs and the bulma css framework, but it seems like it is having an impact on the whole admin area.

Is it possible to load my css only on my plugin admin page?

I am trying to build a wp plugin using vuejs and the bulma css framework, but it seems like it is having an impact on the whole admin area.

Is it possible to load my css only on my plugin admin page?

Share Improve this question edited Dec 17, 2018 at 21:58 Dan Gayle 6,1665 gold badges33 silver badges45 bronze badges asked Dec 15, 2018 at 14:14 fefefefe 8943 gold badges14 silver badges34 bronze badges 1
  • Did you read the documentation ? codex.wordpress/Plugin_API/Action_Reference/… – shanebp Commented Dec 15, 2018 at 20:59
Add a comment  | 

1 Answer 1

Reset to default 1

To answer the question, from the codex, listed above in the comments.

function load_custom_wp_admin_style($hook) {
        // Load only on ?page=mypluginname
        if($hook != 'toplevel_page_mypluginname') {
                return;
        }
        wp_enqueue_style( 'custom_wp_admin_css', plugins_url('admin-style.css', __FILE__) );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

Note: If you are unsure what your $hook name is .. use this to determine your hookname. Put the code after the { from the function.

wp_die($hook);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749090093a316277.html

最新回复(0)