My theme has "selecting differrent google fonts options" So for that we need to load several .woff2 files. So i have added 2 type of woff2 files in Top of CSS file (Bitter & Lora). but i don't know How to change in funtions.php

Here is my Funtions.php font code:-

 * Enqueue scripts and styles
 * @since Cazuela 1.0
function thsp_theme_scripts() {
     * Enqueue Google Fonts
     * Check if fonts set in theme options require loading
     * of Google scripts
    $theme_options = thsp_cbp_get_options_values();
    $theme_options_fields = thsp_cbp_get_fields();
    $body_font_value = $theme_options['body_font'];
    $heading_font_value = $theme_options['heading_font'];
    $body_font_options = $theme_options_fields['thsp_typography_section']['fields']['body_font']['control_args']['choices'];
    $heading_font_options = $theme_options_fields['thsp_typography_section']['fields']['heading_font']['control_args']['choices'];

    // Check if it's a Google Font
    if( isset( $body_font_options[$body_font_value]['google_font'] ) ) {
            'font_' . $body_font_value,
            'http://fonts.googleapis.com/css?family=' . $body_font_options[$body_font_value]['google_font']
    // Check if it's a Google Font
    if( isset( $heading_font_options[$heading_font_value]['google_font'] ) ) {
            'font_' . $heading_font_value,
            'http://fonts.googleapis.com/css?family=' . $heading_font_options[$heading_font_value]['google_font']
    wp_enqueue_style( 'style', get_stylesheet_uri() );
  • Why do you need it directly in style.css? Sep 7, 2016 at 10:22
  • For descresing page size... i will save more than 100kb size (if someone provide me correct code for function.php) i.imgur.com/Zd7WY0e.jpg Sep 7, 2016 at 10:48
  • Using @import method in your CSS to include fonts/stylesheet files won't make your page load speed faster, see this answer
    – 99teko
    Sep 7, 2016 at 11:28
  • @Omar Soliman , I am not using @ Import method i am using directly woff2 file i.imgur.com/Zd7WY0e.jpg ... which is most important for page speed (i have already done on other website) but unable to understant in this theme. Sep 7, 2016 at 15:17

1 Answer 1


I have registered google fonts in my theme function file, then used it in style.css.

function register_google_fonts() {

  wp_register_style( 'googleFonts', 'http://fonts.googleapis.com/css?family=Open+Sans:400,300');
  wp_enqueue_style( 'googleFonts');

add_action( 'wp_enqueue_scripts', 'register_google_fonts' );


.cssClass {

    font-family: 'Open Sans', sans-serif;



First, theme will try to load the Google font Open Sans if not then use the next font sans-serif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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