add menu page - Not able to show the add_menu_page icon

admin2025-05-31  0

I am working a plugin development. I want to show an icon on the menu Page. I am using the following code :

add_menu_page('pms_rohitashv','PMS','subscriber','pms_rohitashv-main', plugin_dir_url( __FILE__ ).'icon.png');

I am using the plugin icon size 16X16 but the icon shown on the menu is gear icon. I want to change it with the custom icon.

What mistake I am making in the code

I am working a plugin development. I want to show an icon on the menu Page. I am using the following code :

add_menu_page('pms_rohitashv','PMS','subscriber','pms_rohitashv-main', plugin_dir_url( __FILE__ ).'icon.png');

I am using the plugin icon size 16X16 but the icon shown on the menu is gear icon. I want to change it with the custom icon.

What mistake I am making in the code

Share Improve this question edited May 15, 2018 at 9:10 fuxia 107k39 gold badges255 silver badges461 bronze badges asked May 15, 2018 at 6:46 lord_linuslord_linus 1057 bronze badges 1
  • the icon is on the 6th argument and not on the 5th developer.wordpress/reference/functions/add_menu_page – mmm Commented May 15, 2018 at 7:53
Add a comment  | 

1 Answer 1

Reset to default 0

You have added the directory name where do you have stored the icon and this should be the 6th argument rather than 5th.

add_menu_page(
    'pms_rohitashv',
    'PMS',
    'subscriber',
    'pms_rohitashv-main',
    '', 
    plugin_dir_url( __FILE__ ).'/images/icon.png'
);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748630661a313653.html

最新回复(0)