Wordpress Snippets

Using Google Fonts In WordPress – The Right Way

Add this in functions.php replacing the font of course.

/**
 * Adding Goolge Fonts To WordPress - The Right Way
 *
 * @refer  https://wp-mix.com/right-way-include-google-fonts-wordpress/
 */
function right_way_to_include_google_fonts() {
  if (!is_admin()) {
    wp_register_style('google', 'https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700', array(), null, 'all');
    wp_enqueue_style('google');
  }
}
add_action('wp_enqueue_scripts', 'right_way_to_include_google_fonts');

Hire Us. Or just say Hi!
Need a job? Apply to get one.