WordPress 所有的 Dashicons 和其 CSS Class 以及 CODE

Dashicons 是WordPress 3.8 版本引进的图标字体,在WordPress 3.9 版本又增加了 30 个, 在后台我们可以直接使用这些 Dashicons 图标 ,只要知道他的 CSS Class 或者 CODE。前台可能复杂一些,首先需要通过以下代码载入 Dashicons 的 css 文件,然后用法就一样了:


add_action( 'wp_enqueue_scripts', 'wpjam_load_dashicons' );
function wpjam_load_dashicons() {
    wp_enqueue_style( 'dashicons' );
}

但是无论如何都要知道 Dashicons 的 CSS Class 和 Code,为了方便自己和大家查询和使用,下面我就列出所有的 Dashicons 和它的 CSS class 以及 Code,欢迎大家收藏和转载:

后台菜单 – Admin Menu

图标 CSS Class Code
dashicons-menu f333
dashicons-admin-site f319
dashicons-dashboard f226
dashicons-admin-post f109
  dashicons-admin-media f104
dashicons-admin-links f103
dashicons-admin-page f105
  dashicons-admin-comments f101
dashicons-admin-appearance f100
dashicons-admin-plugins f106
  dashicons-admin-users f110
dashicons-admin-tools f107
dashicons-admin-settings f108
dashicons-admin-network F112
dashicons-admin-home F102
dashicons-admin-generic F111
dashicons-admin-collapse F148

欢迎界面 – Welcome Screen

图标 CSS Class Code
dashicons-welcome-write-blog f119
dashicons-welcome-edit-page f119
dashicons-welcome-add-page f133
dashicons-welcome-view-site f115
dashicons-welcome-widgets-menus f116
  dashicons-welcome-comments f117
dashicons-welcome-learn-more f118

日志格式 – Post Formats

图标 CSS Class Code
dashicons-format-standard f109
dashicons-format-aside f123
dashicons-format-image f128
dashicons-format-gallery f161
dashicons-format-video f126
dashicons-format-status f130
dashicons-format-quote f122
dashicons-format-links f103
dashicons-format-chat f125
dashicons-format-audio f127
dashicons-camera f306
dashicons-images-alt f232
dashicons-images-alt2 f233
dashicons-video-alt f234
dashicons-video-alt2 f235
dashicons-video-alt3 f236

媒体 – Media

图标 CSS Class Code
  dashicons-media-archive f501
  dashicons-media-audio f500
  dashicons-media-code f499
  dashicons-media-default f498
  dashicons-media-document f497
  dashicons-media-interactive f496
  dashicons-media-spreadsheet f495
  dashicons-media-text f491
  dashicons-media-video f490
dashicons-playlist-audio f492
dashicons-playlist-video f493

图标编辑 – Image Editing

图标 CSS Class Code
dashicons-image-crop f165
dashicons-image-rotate-left f166
dashicons-image-rotate-right f167
dashicons-image-flip-vertical f168
dashicons-image-flip-horizontal f169
dashicons-undo f171
dashicons-redo f172

富文本编辑 – TinyMCE

图标 CSS Class Code
dashicons-editor-bold f200
dashicons-editor-italic f201
dashicons-editor-ul f203
dashicons-editor-ol f204
dashicons-editor-quote f205
dashicons-editor-alignleft f206
dashicons-editor-aligncenter f207
dashicons-editor-alignright f208
dashicons-editor-insertmore f209
dashicons-editor-spellcheck f210
dashicons-editor-distractionfree f211
dashicons-editor-expand f211
dashicons-editor-contract f506
dashicons-editor-kitchensink f212
dashicons-editor-underline f213
dashicons-editor-justify f214
dashicons-editor-textcolor f215
dashicons-editor-paste-word f216
dashicons-editor-paste-text f217
dashicons-editor-removeformatting f218
dashicons-editor-video f219
dashicons-editor-customchar f220
dashicons-editor-outdent f221
dashicons-editor-indent f222
dashicons-editor-help f223
dashicons-editor-strikethrough f224
dashicons-editor-unlink f225
dashicons-editor-rtl f320
dashicons-editor-break f464
dashicons-editor-code f475
dashicons-editor-paragraph f476

日志 – Posts

图标 CSS Class Code
dashicons-align-left f135
dashicons-align-right f136
dashicons-align-center f134
dashicons-align-none f138
dashicons-lock f160
dashicons-calendar f145
dashicons-visibility f177
dashicons-post-status f173
dashicons-edit f464
dashicons-trash f182

排序 – Sorting

图标 CSS Class Code
dashicons-external f504
dashicons-arrow-up f142
dashicons-arrow-down f140
dashicons-arrow-right f139
dashicons-arrow-left f141
dashicons-arrow-up-alt f342
dashicons-arrow-down-alt f346
dashicons-arrow-right-alt f344
dashicons-arrow-left-alt f340
dashicons-arrow-up-alt2 f343
dashicons-arrow-down-alt2 f347
dashicons-arrow-right-alt2 f345
dashicons-arrow-left-alt2 f341
dashicons-sort f156
dashicons-leftright f229
dashicons-randomize f503
dashicons-list-view f163
dashicons-exerpt-view f164

社交 – Social

图标 CSS Class Code
dashicons-share f237
dashicons-share-alt f240
dashicons-share-alt2 f242
dashicons-twitter f301
dashicons-rss f303
dashicons-email f465
dashicons-email-alt f466
dashicons-facebook f304
dashicons-facebook-alt f305
dashicons-googleplus f462
dashicons-networking f325

WP 相关

图标 CSS Class Code
dashicons-hammer f308
dashicons-art f309
dashicons-migrate f310
dashicons-performance f311
dashicons-universal-access f483
dashicons-universal-access-alt f507
dashicons-tickets f486
  dashicons-nametag f484
dashicons-clipboard f481
dashicons-heart f487
dashicons-megaphone f488
dashicons-schedule f489

内部/产品 – Internal/Products

图标 CSS Class Code
dashicons-wordpress f120
dashicons-wordpress-alt f324
dashicons-pressthis f157
dashicons-update f463
dashicons-screenoptions f180
dashicons-info f348
dashicons-cart f174
dashicons-feedback f175
dashicons-cloud f176
dashicons-translation f326

自定义分类 – Taxonomies

图标 CSS Class Code
dashicons-tag f323
dashicons-category f318

窗体 – Widgets

图标 CSS Class Code
dashicons-archive f478
dashicons-tagcloud f479
dashicons-text f480

警告/通知/旗帜 – Alerts/Notifications/Flags

图标 CSS Class Code
dashicons-yes f147
dashicons-no f158
dashicons-no-alt f335
dashicons-plus f132
dashicons-plus-alt f502
dashicons-minus f460
dashicons-dismiss f153
dashicons-marker f159
dashicons-star-filled f155
dashicons-star-half f459
dashicons-star-empty f154
dashicons-flag f227

其他杂项 – MISC/CPT

图标 CSS Class Code
dashicons-location f230
dashicons-location-alt f231
dashicons-vault f178
dashicons-shield f332
dashicons-shield-alt f334
dashicons-sos f468
dashicons-search f179
dashicons-slides f181
dashicons-analytics f183
dashicons-chart-pie f184
dashicons-chart-bar f185
dashicons-chart-line f238
dashicons-chart-area f239
dashicons-groups f307
dashicons-businessman f338
dashicons-id f336
dashicons-id-alt f337
dashicons-products f312
dashicons-awards f313
dashicons-forms f314
dashicons-testimonial f473
dashicons-portfolio f322
dashicons-book f330
dashicons-book-alt f331
dashicons-download f316
dashicons-upload f317
dashicons-backup f321
dashicons-clock f469
dashicons-lightbulb f339
dashicons-microphone f482
dashicons-desktop f472
dashicons-tablet f471
dashicons-smartphone f470
dashicons-smiley f328
### 回答1: Certainly! Here's a simple demo code to demonstrate how to use the `comments_open()` function in WordPress: ``` <?php $post_id = get_the_ID(); if (comments_open($post_id)) { echo 'Comments are open for this post.'; } else { echo 'Comments are closed for this post.'; } ?> ``` In this code, we first get the ID of the current post using the `get_the_ID()` function. Then, we pass the post ID to the `comments_open()` function to check if comments are open for this post. If comments are open, the function returns `true`, and we display the message "Comments are open for this post." If comments are closed, the function returns `false`, and we display the message "Comments are closed for this post." This is a very simple example, but you can use the `comments_open()` function in more complex ways, such as to conditionally display comment forms or to customize the behavior of comment-related functions based on whether comments are open or closed. ### 回答2: `comments_open()`是WordPress中的一个函数,用于检查指定的文章或页面是否允许评论。以下是一个`comments_open()`的演示代码。 ```php <?php // 获取当前文章的ID $post_id = get_the_ID(); // 检查当前文章是否允许评论 if ( comments_open( $post_id ) ) { echo '该文章允许评论'; } else { echo '该文章不允许评论'; } ?> ``` 在上面的代码中,首先我们使用`get_the_ID()`函数获取了当前文章的ID,并将其赋值给变量`$post_id`。然后,我们调用了`comments_open()`函数,并将我们获取到的文章ID作为参数传递给它。 接着,通过使用条件判断语句`if...else`,我们检查`comments_open()`函数的返回值。如果返回`true`,即该文章允许评论,则输出字符串"该文章允许评论";如果返回`false`,即该文章不允许评论,则输出字符串"该文章不允许评论"。 通过这段演示代码,我们可以根据需要来判断某篇文章是否允许评论,并根据结果进行相应的处理或输出。这在开发WordPress主题或插件时非常有用。 ### 回答3: `comments_open()`是WordPress中的一个函数,用于判断当前文章(或页面)是否开启了评论功能。以下是一个`comments_open()`的演示代码。 ```php <?php // 获取当前文章的ID $post_id = get_the_ID(); // 检查当前文章是否开启了评论功能 if (comments_open($post_id)) { // 如果开启了评论功能,则显示评论表单 comment_form(); } else { // 如果未开启评论功能,则显示一个提示信息 echo '评论已关闭。'; } ?> ``` 在上述代码中,我们首先使用`get_the_ID()`函数获取当前文章的ID,并将其赋值给变量`$post_id`。然后,通过调用`comments_open()`函数并传入文章ID作为参数,检查评论功能是否开启。 如果`comments_open()`函数返回`true`,则表示评论功能已经开启。我们可以使用`comment_form()`函数来显示评论的表单,以供用户填写评论内容并提交。 如果`comments_open()`函数返回`false`,则表示评论功能已关闭。我们可以通过输出一个提示信息来告知用户评论已经关闭。 通过使用`comments_open()`函数,我们可以根据需要在适当的时候显示或隐藏评论表单,以实现灵活的评论管理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值