1

How can I load Google font only if custom logo is not uploaded?

I know how to load resource if we are on this or that page, but not sure how to do this?

  • Are you, or your theme, using add_theme_support( 'custom-logo' ) to allow custom logos? – Jacob Peattie Jul 27 '17 at 12:19
0

There is a function for this purpose, called has_custom_logo(). You can check whether the website has a custom logo or not by having this conditional:

if ( ! has_custom_logo() ) {
    // Enqueue some google fonts
    wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400' );
}
  • Thanks it works! Didn't know that I can use has_custom_logo() inside functions.php, thanks! – Nemanja Jul 27 '17 at 12:33
1

The code is not tested but is a good starting point, you may need to add action to enqueue the css or you can write a functions and add the code below into it.

  // Enable Custom Logo
      add_theme_support( 'custom-logo', array(
          'height'      => 200,
          'width'       => 400,
          'flex-width' => true,
      ) );

    $old_logo = get_theme_mod( 'header_logo' );
    if ( $old_logo ) {

      wp_enqueue_style( 'wpse_89494_style_3', get_template_directory_uri() . '/your-style_3.css' );

    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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