I have added a menu page to my plugin. In the wp codex is described that I can use a seperate .php file for the content of the menu.

function register_custom_menu_page() {
   add_menu_page('custom menu title', 'custom menu', 'add_users', 'myplugin/myplugin-index.php', '',   plugins_url('myplugin/images/icon.png'), 6);


   echo "Admin Page Test";

Now I want to use custom styles (.css) in the myplugin-index.php. How can this be achieved?



2 Answers 2


You could use

<!doctype html>
<style type="text/css">
display:none !important;
height:auto !important;
<div class="update-nag">
   echo "Admin Page Test";

You can enqueue this way

function prefix_add_my_stylesheet() {
        wp_register_style( 'prefix-style', plugins_url('style.css', __FILE__) );
        wp_enqueue_style( 'prefix-style' );
add_action( 'admin_enqueue_scripts', 'prefix_add_my_stylesheet' );

Reference: http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts#Example:_Load_CSS_File_on_All_Admin_Pages

  • Won't this load the CSS file on any single page of the WordPress admin? Commented Sep 10, 2021 at 17:13

You can use wp_enqueue_style.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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