Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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);
}

myplugin-index.php

<?php
   echo "Admin Page Test";
?>

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

BR,

mybecks

share|improve this question
add comment

migrated from stackoverflow.com Aug 16 '12 at 13:46

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 0 down vote accepted

You could use

<!doctype html>
<head>
<style type="text/css">
#toplevel_page_custom_menu_title{
display:none !important;
}
.update-nag{
height:auto !important;
}
</style>
</head>
<body>
<div class="update-nag">
<?php
   echo "Admin Page Test";
?>
</div>
</body>
</html>

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

share|improve this answer
add comment

You can use wp_enqueue_style.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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