自定义帖子类型的菜单图片 [英] Menu image for custom post type

查看:138
本文介绍了自定义帖子类型的菜单图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自定义帖子类型。我想对帖子类型使用自定义菜单图像。
我知道‘menu_icon’=>’应该可以,但是无法识别应如何指定图像路径。感谢您的帮助。

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.

推荐答案

最好提供图像的完整路径。诸如此类

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

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

编辑:如果您要包含来自Plugin目录的图像,则可以使用 plugin_url()函数。

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

这篇关于自定义帖子类型的菜单图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆