简体   繁体   中英

How to import fontawesome to Roots Theme? (WordPress)

I've locally compiled the fontawesome.less to my main.min.css , and also changed the font path in variables.less , but I still having problem with loading the icons? Can't figure out why. I've successfully loaded it through this way on my local html file but can't get through on WordPress. BTW, I'm using WinLess as my LESS compiler.

You have to make sure that your final minified CSS is linking to the fonts. It sounds like you're missing the path to the fonts – check your inspector tool.

Another alternative is to load from a CDN, eg

/**
 * Enqueue javascript
 *
 */
if( !function_exists( "theme_js" ) ) {

    function theme_js(){

        wp_register_script( 'fontawesome', 'https://use.fontawesome.com/9a8a083038.js',
            array('jquery'),
            '4.7.1', true);


        wp_enqueue_script( 'fontawesome' );

    }
}
add_action( 'wp_enqueue_scripts', 'datonomy_theme_js' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM