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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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__);
回答2:
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',