Skip to content

Instantly share code, notes, and snippets.

@UeldoTheme
Created April 13, 2018 13:25
Show Gist options
  • Save UeldoTheme/87d194069f859c19f7ef34e157019eb0 to your computer and use it in GitHub Desktop.
Save UeldoTheme/87d194069f859c19f7ef34e157019eb0 to your computer and use it in GitHub Desktop.
Example child theme which allows you to add custom font from Google Fonts to your WordPress theme.
<?php
/**
*
* child theme functions and definitions
*
*/
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_scripts' );
function child_theme_enqueue_scripts() {
# enqueue google font with this code line
wp_enqueue_style( 'child-theme-fonts', add_query_arg( 'family', 'Roboto', '//fonts.googleapis.com/css' ), array(), null );
# enqueue parent theme style
wp_enqueue_style( 'child-theme-parent-style', get_template_directory_uri() .'/style.css' );
# enqueue child theme style
wp_enqueue_style( 'child-theme-style', get_stylesheet_directory_uri() .'/style.css', array( 'child-theme-parent-style' ) );
}
/**
*
* end of file.
*
*/
?>
/*
Theme Name: Child theme
Template: YOUR_ORIGINAL_THEME_NAME_HERE
*/
h1 {
font-family: 'Roboto';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment