Menu image for custom post type

2019-07-28 05:10发布

I'm working with custom post type. I want to use custom menu image for the post type. I know 'menu_icon' => '' should work but couldn't recognize how image path should be specified. I appreciate your help.

2条回答
相关推荐>>
2楼-- · 2019-07-28 05:57

It is better to give the full path to the image. Something like this

'menu_icon' => get_bloginfo('template_directory') . '/images/portfolio-icon.png'

Edit: If you want to include the image from the Plugin directory, then you can use the plugin_url() function. This will make it compatible with WPMU as well.

'menu_icon' => plugins_url('path/to/image',  __FILE__);
查看更多
\"骚年 ilove
3楼-- · 2019-07-28 06:02

Other way to do it, if the image you want to add is located in your theme directory, would be:

'menu_icon' => get_template_directory_uri() . '/images/your_custom_icon.png',
查看更多
登录 后发表回答