Font Awesome is the ever useful font set for icons of all flavours. Version 4.7 is free and easily added to your WordPress website by a couple of methods.
Firstly we can use a CDN to queue up the script in WordPress.
This code should be added to your child theme functions.php file – just tonk it right at the bottom. but inside any ‘?>‘. If you’re not using a child theme then think about the FontAwesome plugin or if you feel confident, smash it straight in your functions.php file in the theme directory.
/** * Enqueue Font Awesome font */ function nnm_add_fontawesome() { wp_enqueue_style('fontawesome', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', false, null); } add_action('wp_enqueue_scripts', 'nnm_add_fontawesome', 100);
or as an anonymous function (php 7 and above).
/** * Enqueue Font Awesome font CDN */ add_action('wp_enqueue_scripts', function () { wp_enqueue_style('fontawesome', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', false, null); }, 100);
Setup an account with FontAwesome and replace “pqrstuvwxyz” with your code to use the js version!
/** * Enqueue Font Awesome font JS */ add_action('wp_enqueue_scripts', function () { wp_enqueue_script('fontawesome', 'https://use.fontawesome.com/'pqrstuvwxyz.js', false, null); }, 100);
Once you have Font Awesome included you can use the icons as shortcodes with this snippet here, within your contact forms, as css pseudo elements or anywhere throughout your website using the standard Font Awesome html icons.