Load WordPress Dashicon on frontend

By default WordPress has dashicon in the backend , Where normally you use it for your custom post type icon. The css for dashicon is not loaded on frontend. However at some cases you would love to include the dashicon on the frontend side. For example if you are creating frontend login and registration forms then you can use the default arrow in checkbox (when checkbox is ticked) on login page to save your username and password.

Loading dashicon on frontend is super easy, you just have to enqueue the style in your theme’s funnction.php file.

Add Following code to your theme’s function.php file

<?php
add_action( 'wp_enqueue_scripts', 'mytheme_scripts' );

/******************************************
 *
 * Enqueue Dashicons style for frontend use
 *
 *****************************************/
function mytheme_scripts() {
	  wp_enqueue_style( 'dashicons' );
}

?>

Here are the list of Daschicon you can use

https://developer.wordpress.org/resource/dashicons/#unlock

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s