Already we had known that Google Web Fonts will vastly improve, especially interface websites. Well, Google Web Fonts is also offers really easy to use non-standard fonts on your websites. They have over 180 fonts and counting. We can directly check out at http://www.google.com/fonts/
Google is also providing clear instructions on how to embed their fonts, so you don’t difficult need knowledge or instruction to explore it. For WordPress platform, there’s a much better how to use Google Web Fonts. You can using the wp_enqueue_style function and just put a few line codes to making it working.
The code that Google gave us will look like below:
But we can create a function to registers the stylesheet for using ‘googleFonts’ with the URL provided by Google. Just open functions.php file on existing theme folder and copy these codes.
1 2 3 4 5 6 7 8 9 10 |
function load_gfonts() { wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Rock+Salt|Neucha'); wp_enqueue_style( 'googleFonts'); } add_action('wp_print_styles', 'load_gfonts'); |
This way is much better practice when you’re using WordPress with child themes. So you don’t worry to update the parent’s header.php and your child theme because these methods will keep your themes portable and plugin-friendly.