在 wordpress 中将字体图标(如 font awesome 或 genericons)设置为自定义 menu_icon
Set a font icon like font awesome or genericons as a custom menu_icon in wordpress
我现在要在 wordpress 中添加自定义 post 类型。
function custom_post_type() {
$labels = array(
'name' => 'Custom Type',
'singular_name' => 'Custom Type',
'menu_name' => 'Custom Type',
// ....
);
$args = array(
// ...
// The below matters!
'menu_icon' => get_template_directory_uri().'/images/my-icon.png',
);
register_post_type( 'custom_type', $args );
}
add_action( 'init', 'custom_post_type', 0 );
我的烦恼是:
我想将 menu_icon
设置为字体图标,例如 font-awesome 或 genericons。
我该怎么办?
虽然这不是我问题的完整解决方案,但它解决了我的问题:
3.8 之后的 Wordpress 使用 dashicons 的子集作为其菜单图标。
如果我们要使用图标集的图标集,只写图标名称即可。
例如
'menu_icon' => 'dashicons-welcome-view-site',
参见:
https://developer.wordpress.org/resource/dashicons/#format-image
我写了一个post作为例子:
http://www.huangwenchao.com.cn/2015/03/wordpress-dashicon.html
我现在要在 wordpress 中添加自定义 post 类型。
function custom_post_type() {
$labels = array(
'name' => 'Custom Type',
'singular_name' => 'Custom Type',
'menu_name' => 'Custom Type',
// ....
);
$args = array(
// ...
// The below matters!
'menu_icon' => get_template_directory_uri().'/images/my-icon.png',
);
register_post_type( 'custom_type', $args );
}
add_action( 'init', 'custom_post_type', 0 );
我的烦恼是:
我想将 menu_icon
设置为字体图标,例如 font-awesome 或 genericons。
我该怎么办?
虽然这不是我问题的完整解决方案,但它解决了我的问题:
3.8 之后的 Wordpress 使用 dashicons 的子集作为其菜单图标。
如果我们要使用图标集的图标集,只写图标名称即可。
例如
'menu_icon' => 'dashicons-welcome-view-site',
参见:
https://developer.wordpress.org/resource/dashicons/#format-image
我写了一个post作为例子:
http://www.huangwenchao.com.cn/2015/03/wordpress-dashicon.html