I am rebuilding my website and want to use a font I purchased from MyFonts.com and need to add <link rel="stylesheet" type="text/css" href="MyFontsWebfontsKit.css">, but I don't know where or how this should be added.

I am a WP novice so need step-by-step easy to understand instructions please.

| improve this question | | | | |

The WordPress API provides the functions wp_enqueue_style() and wp_enqueue_script() for including stylesheets and JavaScript.

These functions should be used instead of hardcoding style or script tags within HTML.

// Runs wpse_enqueue_styles() on the wp_enqueue_scripts() hook.
// (Yes, we're enqueuing a stylesheet here, but the proper hook is wp_enqueue_scripts.
add_action( 'wp_enqueue_scripts', 'wpse_enqueue_styles' );
function wpse_enqueue_styles() {

            // Handle

            // Source (URL) for stylesheet.
            // Here, the stylesheet resides at /theme-name/css/MyFontsWebfontsKit.css
            get_stylesheet_directory_uri() . '/css/MyFontsWebfontsKit.css',

            // Dependencies for stylesheet. None in this case.

Place the code above in your theme's functions.php file. Note that the "wpse_" prefix should be changed to match whatever is used by your theme.

| improve this answer | | | | |
  • Thank you for your reply Dave. I forgot to mention I am building my site offline using wamp. Does this matter? I STILL can't get this to load my choice of font. It's driving me crazy. – Karen Feb 23 '18 at 23:32
  • Using Wamp should not matter. (I tested the code I posted using Xampp.) First make sure that the stylesheet is being loaded using your browser's developer tools. You might want to try a test stylesheet that contains something like * { color: purple !important; }. Once you've verified that the test styles work, then try working with the actual font styles. – Dave Romsey Feb 23 '18 at 23:48
  • 1
    Thank you again for your help Dave! I wound up putting their CSS in MY CSS file and it worked perfectly. I'm pretty sure I had the links wrong doing it the other way though. – Karen Mar 6 '18 at 3:50
  • You got it! I'm glad that the solution worked, and thank you for following up. – Dave Romsey Mar 6 '18 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.