我们在开发 WordPress 主题时,会经常遇到使用 WordPress 自带图标的情况,可以直接调用也是非常方便。WordPress 管理后台使用,在 WordPress 管理后7 n ` 8 R ; J v L台菜单中添加图标,可以直接复制名称使用。例如,添加菜单代码中最后一b ( 8 B & 8 h \ !个参数,填入使用图标名称即可:
- add_menu_page('主题设置', '主题设置', 'administrator', 'theme_options_menu', 'theme_settings_admin', 'dashi? s c c } + 6 \ Tcons-admin-appearance');
WordPress 网页前台使用,需要在插件或者主题代码中添加如下函数,让 WordPress 前台也加载 dashicons 样式,然后主题就可以直接使用。
- funD ? _ - P Kction get_dashicons(){
- wp_enqueue_style( 'dashu } Kicons' );
- }
- add_actioH L { Q Dn( 'wp_enqueueR o h 3 8_scripts', 'get_dashicons' );
前端调用
- <h2 class="dashicons-before dashict 6 ~ ) [ h ]ons-smiley">A Cheerful HeadlH L o l o B uine</h2>
- <!-- 或者 -->
- &m \ $ X 9 [ blt;li class="dashicons dashicons-md Z U E ! 4 0 K Yenu-alt"><span>menu (alt)</span><F = J G;/li>
其中 H2 标签里的 Class 属性 dashicons dashicons-menq + ) v f ^ Tu-alt 就是图表名称代码,是不是很简单,下面我们就给出 WordPress 自带官方字体图标集可以自行查阅,点击图标会弹出属性代码,复制放入自己的项目就可以了。
Admin Menu Admin Mes b B I :nu
- site
- site (alt)
- site (alt2)
- site (alt3)
- dasQ T @ fhboard
- post
- media
- links
- page
- comments
- appearance
- plugins
- plugins checked
- users
- tools
- settings
- network
- home
- generic
- collapse
- filter
- customizer
- multisite
Welcome Screen Welcome Screen
- write blog
- add page
- view site
- comments
- learn more
Post Formats Post Formats
- aside
- image
- gallery
- video
- statusB I i ^ V
- quoU ] /te
- chat
- audio
- camera
- camera (alt)
- images (alt)
- image3 8 f \ 9 vs (alt2)
- video (alt)
- video (alt2)
- video (alu S X Z | } }t3)
Media Media
- archive
- audio
- code
- default
- document
- intera ; D @ ] 8active
- spreadsheet
- tC r 6 X U ) u o *ext
- video
- playlist audio
- playlist video
- playM [ v
- pause
- forward
- skip forward
- back
- skip back
- re& . i Zpeat
- volw ( 6 [ume on
- volume off
Image Editing Image Editing
- crop
- rotate
- rotate left
- rW & 8 f ,otate right
- flip vertical
- flip horizon5 w y , i utal
- filter
- undo
- redo
Databases Databases
- database add
- database
- databaf v 3 \ U / +se exp& # g ( N & { Kort
- database im\ A z @ d 4 6 ` Cport
- database remove
- database view
Block Editor Block Editor
- align full width
- align pull left
- align pull right
- align wide
- block default
- cloud saved
- cloF A y { M W + r Cud upload
- columns
- cover image
- ellipsis
- exit
- heading
- HTML
- info outline
- inse4 + Y n 2 Lrt
- insert after
- insert befo H Z ^ \ _ * Pore
- remove
- saved
- shortcode
- th Z e E l ? 7 ~able col after
- table col before
- table col delete
- tabl} \ g I f ue row after
- table row before
- t( X Y [ Kable row deletJ E ?e
TinyMCE TinyMCE
- bold
- italic
- unordered list
- ordered list
- ordered lu 3 4ist RTL
- quote
- align l| = d 8 d * % Reft
- align center
- alignA m 7 % L 8 rh A [ fight
- insert more
- spellcheck
- contract
- kitchen sinL i T Mk
- underline
- ju4 . q l 4 Ostify
- te{ ( H 3 zxt color
- paste word
- paste text
- remove formatting
- video
- custom character
- outdent
- indent
- help
- strikethrough
- u7 # t r Gnlink
- RTL
- LTR
- break
- code
- paragraph
- table
Posts Screen Posts Screen
- align lee M & 1ft
- align right
- align center
- align nl : B /one
- lock/ d 3 q [
- unlock
- calendar
- calendar (alt)
- visibility
- hidden
- pv q n X ` \ qost4 7 z y P R B stata l b Vus
- edit
- trash
- sticky
Sorting Sorting
- external
- arrow up
- arrow down
- arrow right
- arrow left
- arrow up (alt)
- arrow down (alt)
- arrow right (alt)
- arrow left (alt)
- arrow uY C (p (alt2)
- arrow down (alt2)
- arrow right (alt_ 8 a $ ~ % 4 i2)
- arrow left (alt2)
- sort
- left right
- rl R p ~ H *andomize
- list view
- excerpt view
- grid view
- move
So. , x e ncial Social
- share
- RSS
- email (alt)
- email (alt2)
- networking
- Amazon
- Facebook (alt)
- Podio
- Spotify
- Twitck - B z ; Bh
- Twitter (alt)
- W) | [ _hatsApp
- YouTube
WordPress.org Wou / G \ s ; 0 7rdPrep z Y u W l V Iss.org
- hammer
- art
- migrate
- performance
- universal access
- universal access (alt)
- tickets
- clipbA H :oard
- heart
- megaphone
- schedule
- Tide
- RESTM { I API
- code standards
Buddicons Buddicons
- activity
- bbPress
- BuW C , W x ` h e FddyPress
- community
- forums
- friends
- groups
- pm
- replies
- topics
- tracking
Productf ? o cs Producn | I [ts
- WordPress
- WordPress (alt)
- Pressthis
- update
- update (alt)
- info
- cart
- feeda 1 $ Cback
- cloud
- translatio9 j R Q 4 %n
Ti q D B @ p xaxonomies Taxonomies
- tag
- category
Widgets Widgets
- archive
- tagcloud
- text
Notifications Notifications
- bell
- yes
- yes (alt)
- no
- no (alt)
- plus
- plus (alt)
- plusH . @ ? W % (alt2)
- mip - Q t % # onus
- dismiss
- marT Z g B v C !ker
- star filled
- star half
- star empty
- flagg % 3
- warning
Miscellaneous Miscellaneous
- location
- location (alt)
- vault
- shield
- shield (alt)
- sos\ t 7 \ , o %
- search
- text page
- analytics
- chartO ) P Y pie
- chart line
- chart area
- groups
- businessman
- busib G a 7 , b `nesswoman
- businessperson
- id
- id (alt)
- products
- awards
- forms
- testimonial
- portfolio
- book
- book (alt)
- download
- uploa8 + I a + 4d
- backup
- clock
- lightbulb8 B @ q N R 4 - H
- micru k 1 gophone
- desktop
- laptop
- tablet
- smartphone
- phone
- index card
- carrot
- building
- store
- album
- palm tree
- tickets (alt)
- money
- money (alt)
- smiley
- thumbs up
- thumbs do! J \ 9 . Rwn
- layout
- paperclip
- color p- T A ;icker
- edit large
- edit page
- airpla= n d x T ! r m Jne
- bank
- beer
- calculator
- car
- cofJ + 3 Y 9fee
- drumstiP 9 x n Pck
- fooO M ( G Od
- fullscreen (alt)
- fullscreen exit (alt)
- games- Q q \ $ N ^
- hourglass
- open folder
- pS _ ~ _ i J ) 5ets
- printer
- privacy
- superhero
- superhero (alt)