WordPress.org

Ready to get started?Download WordPress

Forums

[Theme: Scrappy] google fonts (5 posts)

  1. bob.passaro
    Member
    Posted 2 years ago #

    Why can't I find the link to the Google web fonts that are used in Scrappy (Rochester, for one)?

    I'm expecting to find this:

    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Rochester">

    somewhere in header.php inside the <head> element. Is that not what I should be looking for?

  2. Caroline Moore
    Member
    Posted 2 years ago #

    Themes in the repository (at least, new themes) are required to enqueue any additional stylesheets in functions.php, so you'll find the links to Google fonts there!

  3. bob.passaro
    Member
    Posted 2 years ago #

    Ah, thanks, sixhours. I see it. Looks like this in functions.php:

    function scrappy_print_styles() {
    
    	wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Rochester|Unna|Alegreya:400italic,700italic,400,700');
    	wp_enqueue_style( 'googleFonts');
    
    }
    
    add_action( 'wp_enqueue_scripts', 'scrappy_print_styles' );

    But now I'm curious why (it does seem to work fine in header.php, too) But is putting it in functions.php this way considered a best practice? If so, do you know the reason this is preferable?

  4. Caroline Moore
    Member
    Posted 2 years ago #

    There are a few good reasons I can see off the top of my head... registering and enqueueing the styles keeps them available to other WordPress functions should an admin require more advanced interactions with them. It allows the admin to prioritize and set dependencies for the styles as they load, or only load styles in certain cases (admin panel vs. front end, for instance). It also keeps header.php clean and easy to read at a glance.

    It's possible there are other good reasons of which I'm unaware, but those are the reasons I use enqueued styles, personally.

  5. bob.passaro
    Member
    Posted 2 years ago #

    Thanks! I appreciate your time.

Topic Closed

This topic has been closed to new replies.

About this Topic