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 am trying to create a custom Menu by using the WordPress add_menu_page() function. I think I understand the whole function parameters as Codex point it out as:

<?php 
      add_menu_page( $page_title,
                     $menu_title,
                     $capability,
                     $menu_slug,
                     $function,
                     $icon_url,
                     $position ); 
?>

The only problem which I have is how to point to an existing WP icons liketool, edit, upload and so on.., in $icon_url? I already find this post but I coulnt' figute it out how to add style to div at:

 <?php 
        add_menu_page(
               'custom menu title', 
               'custom menu', 
               'add_users', 
               'myplugin/myplugin-index.php', 
               '', 
               'div', //this part
               6);
  ?>

inside of my .php file?!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The link you provided has the answer, given by Otto as a comment:

Short answer is that you can't. Not only using add_menu_page like that. Those icons WordPress uses are added as background images via CSS, not using the icon_url method that is provided with add_menu_page.

As you said the syntax is:

syntax: add_menu_page( $page_title*, $menu_title*, $capability*, $menu_slug*, $function, $icon_url, $position ); - * required

So I used my custom icon (home.png), placed in a folder (/my_theme/admin/images/) as:

add_menu_page(  
    'Site Options',                     // The title to be displayed on the corresponding page for this menu  
    'Site Options',                     // The text to be displayed for this actual menu item  
    'manage_options',                   // Which type of users can see this menu  
    'sandbox',                          // The unique ID - that is, the slug - for this menu item  
    'sandbox_menu_page_display',    // The name of the function to call when rendering the menu for this page
    get_bloginfo( template_directory ) . '/admin/images/home.png'   // Icon for the Main menu in Admin panel
);
share|improve this answer

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.