WordPress 后台字体图标 Dashicons
Dashicons 是WordPress官方维护的,用于后台管理的字体图标。虽然,数量不是很多,但对于一般的需求也足够用了。
可以在官方查看所有支持的Dashicons 图标:https://developer.wordpress.org/resource/dashicons/#menu
点击图标,就可以看到这个图标的代码,及使用方法等。
主要用法有三种:
1. register_post_type 注册新文章类型,在菜单中显示。
function wpdocs_create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products', 'textdomain' ),
'singular_name' => __( 'Product', 'textdomain' )
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-products',
)
);
}
add_action( 'init', 'wpdocs_create_post_type', 0 );
2. add_menu_page 添加后台管理页面,在菜单中显示。
function wpdocs_add_my_custom_menu() {
// Add an item to the menu.
add_menu_page(
__( 'My Page', 'textdomain' ),
__( 'My Title', 'textdomain' ),
'manage_options',
'my-page',
'my_admin_page_function',
'dashicons-admin-media'
);
}
3. 在HTML中使用
<h2 class="dashicons-before dashicons-smiley">A Cheerful Headline</h2>
-
WordPress函数:add_plugins_page 在后台侧边栏-插件,添加子菜单使用函数 add_plugins_page 在WordPress侧边栏-插件下添加子菜单
-
WordPress函数:add_users_page 在后台侧边栏-用户,添加子菜单WordPress函数 add_users_page 在后台侧边栏【用户】下添加子菜单
-
WordPress函数:add_options_page 在后台侧边栏-设置,添加子菜单WordPress函数 add_options_page 在后台侧边栏-设置,添加子菜单
-
WordPress分类URL自动添加斜杠有些小伙伴肯定开始疑问了,WordPress分类URL为什么要加斜杠,其实主要还是为了搜索引擎,利于SEO,带斜杠的URL样式如下
-
WordPress( .htaccess )如何禁止SQL查询或禁止垃圾信息请求WordPress如何禁止SQL查询或禁止垃圾信息请求,若我们使用Apache引擎或LAMP环境,我们只需要在根目录的 .htaccess 文件中添加以下代码即可。
-
WordPress函数:wp_generate_uuid4 和 wp_is_uuid 生成和判断UUIDWordPress提供了生成和判断UUID的函数
暂无评论,抢个沙发...