PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Google web font not loading when using Gravity forms shortcode in header

  1. Hi

    When using

    <?php echo do_shortcode('[gravityform id="2" name="Contact Mini" title="false" description="false"]'); ?>

    the google webfont "Roboto Condensed" does not load on page refresh. I have tried removing the echoed shortcode and the issue is fixed. If you navigate to any page there is no issue, only when refreshing a page you are already on using a refresh button or hitting f5.

    This issue occurs on windows 7 in Chrome v 24.0.1312.57. I can't replicate it in firefox, safari oe ie9

    <!DOCTYPE html>
    <!-- Add browser classes to html tag -->
    <!--[if lt IE 7]>  <html <?php language_attributes(); ?> class="ie ie6 lte9 lte8 lte7"> <![endif]-->
    <!--[if IE 7]>     <html <?php language_attributes(); ?> class="ie ie7 lte9 lte8 lte7"> <![endif]-->
    <!--[if IE 8]>     <html <?php language_attributes(); ?> class="ie ie8 lte9 lte8"> <![endif]-->
    <!--[if IE 9]>     <html <?php language_attributes(); ?> class="ie ie9 lte9"> <![endif]-->
    <!--[if gt IE 9]>  <html <?php language_attributes(); ?>> <![endif]-->
    <!--[if !IE]> <html <?php language_attributes(); ?>> <![endif]-->
    
    <!--[if lt IE 9]>
       <script>
          document.createElement('header');
          document.createElement('nav');
          document.createElement('section');
          document.createElement('article');
          document.createElement('aside');
          document.createElement('footer');
       </script>
    <![endif]-->
    
    <head>
    <!--
    ******************************************
    Meta stuff
    ******************************************
    -->
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="SKYPE_TOOLBAR" content ="SKYPE_TOOLBAR_PARSER_COMPATIBLE"/>
    <title><?php wp_title('');?></title>
    
    <!--
    ******************************************
    Link stuff
    ******************************************
    -->
    <link rel="icon" type="image/png" href="<?php echo get_template_directory_uri(); ?>/images/favicon.png"/>
    <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Droid+Serif' rel='stylesheet' type='text/css'>
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>"/>
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    
    <!-- Add Wordpress head hook stuff -->
    <?php wp_head();?>
    
    </head>
    
    <!--
    ******************************************
    Start of body
    ******************************************
    -->
    <body <?php body_class(); ?>>
    
    	<div class="wrapper-main">
    
        <div class="header-form">
        	<?php echo do_shortcode('[gravityform id="2" name="Contact Mini" title="false" description="false"]'); ?>
        	<a class="form-tab"></a>
        </div><!-- end header-form -->
    
        	<header class="header">
            	<div class="utility-bar">
                	<div class="contact-info">
    				<?php
    				if( function_exists('get_field') ) {
    					if( get_field('header_contact_details','options') ) {
    						echo do_shortcode( get_field('header_contact_details','options') );
    					}
    				}
    				?>
                    </div>
                	<nav class="nav-utility clearfix"><?php wp_nav_menu( array( 'theme_location' => 'menu-utility', 'container' => '') ); ?></nav>
                </div><!-- end utility-bar -->
            	<div class="header-content">
                	<a class="logo" href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a>
    				<nav class="nav-main"><?php wp_nav_menu( array( 'theme_location' => 'menu-main', 'container' => '') ); ?></nav>
                </div><!-- end header-content -->
            </header><!-- end header -->

    The font is loaded with css from style.css, rule as follows

    font:300 normal 35px 'Roboto Condensed', Arial, Helvetica, sans-serif; color:#00335F;

    I can give access to the development site if you cn provide an ip to unblock.

    Posted 11 years ago on Tuesday February 19, 2013 | Permalink
  2. What is the URL to the page where this form is embedded?

    When you include a Gravity Form like that, you may need to enqueue the Gravity Forms scripts and styles using gravity_form_enqueue_scripts http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts

    More about embedding a form via function call:
    http://www.gravityhelp.com/documentation/page/Embedding_A_Form#Function_Call

    Finally, there is a JavaScript event gform_page_loaded http://www.gravityhelp.com/documentation/page/Gform_page_loaded which is normally used to ensure fonts are loaded after a Gravity Form is reloaded. The example on that page is for Cufon, but the approach would be the same for Google fonts.

    I would start with gravity_form_enqueue_scripts since you are embedding the form outside the loop.

    Posted 11 years ago on Tuesday February 19, 2013 | Permalink