Support

Account

Home Forums ACF PRO Repeater Subfield for wp_enqueue_style Source

Solving

Repeater Subfield for wp_enqueue_style Source

  • I’m banging my head against the wall and probably because it’s way too late at night. I have setup a Repeater Field to include various Google Fonts. See my function below. If I put ‘ ‘ around $sourceGF it shows in source code but with variable name as specificed. I remove the ‘ ‘ and nothing shows at all in source code. Help?

    function ZopixaF_WP_GoogleFonts() {
    		
    		if ( have_rows( 'zopixa_loadgooglefont', 'options' ) ) : while ( have_rows( 'zopixa_loadgooglefont', 'options' ) ) : the_row();
            	
            	$familyGF = get_sub_field('family_name');
            	$sourceGF = get_sub_field('source_url');
            	
            	wp_enqueue_style( $familyGF, $sourceGF, array(), false, 'all' );
    
    		endwhile;
    
    		else :
    
    			// no rows found
    
    		endif;
    		
    		}
    		
    		add_action( 'wp_enqueue_scripts', 'ZopixaF_WP_GoogleFonts' );
  • Can you give me a list of the values that are returned for each of those variables that are not working?

  • Hey John,

    Using var_dump I got the following:

    familyGF –> string ‘Open Sans’ (length=9)
    sourceGF –> string ‘https://fonts.googleapis.com/css?family=Open+Sans:300,400,600’ (length=61)

  • I don’t see anything. I can only think of a few things. The first is that the handle is already registered and you cannot override it. The second is that the space in “Open Sans” is causing a problem since this is used as an ID for the link tag and ID values cannot contain spaces.

    Have you tried enqueuing the stylesheet without using the acf function, by just using

    
    wp_enqueue_style( 'Open Sans', 'https://fonts.googleapis.com/css?family=Open+Sans:300,400,600', array(), false, 'all' );
    
  • you might also try this for the src value

    
    //fonts.googleapis.com/css?family=Open+Sans:300,400,600
    
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Repeater Subfield for wp_enqueue_style Source’ is closed to new replies.