How Do I Add Custom Font Awesome Icons to WordPress?
In this tutorial, we are going to show you how to add custom font awesome icons to your WordPress site. This is a great way to add a bit of personality to your blog or website.
First, we will need to add the font awesome icons to our theme. We can do this by downloading the font awesome files and uploading them to our WordPress site. Once we have the fonts uploaded, we can add the icon directories to our theme using the following code:
Next, we will need to add the following code to our theme’s functions.php file:
// Add custom font awesome icons function add_custom_font_awesome_icons() { // Get the path to the font awesome folders $font_awesome_dirs = WPBakeryShortcodes::get_theme_modules()->find_all(‘font-awesome’); // Add the icons to the appropriate directories $font_awesome_icons = array( // The “normal” icon directory ‘normal’, // The “ios” icon directory ‘ios’, // The “android” icon directory ‘android’, // The “windows” icon directory ‘windows’, // The “mac” icon directory ‘mac’, // The “webfont” icon directory ‘webfont’, ); // Add the path to the fonts we want to use $font_awesome_fonts = WPBakeryShortcodes::get_theme_modules()->find_all(‘font-awesome’); // Loop through the fonts and add the paths to the icons foreach ($font_awesome_fonts as $font_awesome_font) { $font_awesome_icons[strtolower($font_awesome_font)][‘dir’] = dirname($font_awesome_font); } } add_action(‘init’, ‘add_custom_font_awesome_icons’);
We will now need to add a few lines of code to our theme’s functions.php file to enable the icons:
// Enable the custom font awesome icons function enable_custom_font_awesome_icons() { // Get the path to the font awesome folders $font_awesome_dirs = WPBakeryShortcodes::get_theme_modules()->find_all(‘font-awesome’); // Add the icons to the appropriate directories $font_awesome_icons = array( // The “normal” icon directory ‘normal’, // The “ios” icon directory ‘ios’, // The “android” icon directory ‘android’, // The “windows” icon directory ‘windows’, // The “mac” icon directory ‘mac’, // The “webfont” icon directory ‘webfont’, ); // Add the path to the fonts we want to use $font_awesome_fonts = WPBakeryShortcodes::get_theme_modules()->find_all(‘font-awesome’); // Loop through the fonts and add the paths to the icons foreach ($font_awesome_fonts as $font_awesome_font) { $font_awesome_icons[strtolower($font_awesome_font)][‘dir’] = dirname($font_awesome_font); } } add_action(‘init’, ‘enable_custom_font_awesome_icons’);.