[Resolved] generate_typography_customize_list

Home Forums Support [Resolved] generate_typography_customize_list

Home Forums Support generate_typography_customize_list

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #580410
    NBC

    I’m attempting to use the generate_typography_customize_list function to add the three parts of the Barlow family from Google Fonts to the Customizer’s font list.

    I’m following the instructions here.

    I’ve added the relevant code to my child theme’s functions.php file. The typefaces do not show up in the Customizer, however.

    I’m developing this site under localhost, so no site link to share.

    Here’s the code.

    add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
    function tu_add_google_fonts( $fonts ) {
    	$fonts[ 'Barlow' ] = array( 
    		'name' => 'Barlow',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'Barlow Semi Condensed' ] = array( 
    		'name' => 'Barlow Semi Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'Barlow Condensed' ] = array( 
    		'name' => 'Barlow Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	
    	return $fonts;
    }
    GeneratePress 2.1.2
    GP Premium 1.6.2
    #580431
    Leo
    Staff
    Customer Support

    Hi there,

    I copied and paste your code in Code Snippets and it worked for me.

    Did you check at the bottom of the list and or use the search?

    Let me know.

    #581113
    NBC

    Hi, Leo:

    I searched for other discussion threads that covered this topic, as well as the documentation itself. The solution I implemented comes straight out of the GP documentation. Added to the functions.php file of my child theme, the code has no impact whatsoever.

    #581118
    Leo
    Staff
    Customer Support

    There is a bit of misunderstanding πŸ™‚

    I meant search in the customizer typography list.

    I did test your code and it worked for me:
    http://www.screencast.com/t/09GNNU2Y

    #581155
    NBC

    Hi, Leo:

    I tried the Code Snippets plug-in. Turns out it adds the typefaces to the end of the list. I was looking for them to appear alphabetized in with the rest of the list.

    However, the style list does not appear. All three Barlow typeface families include 9 weights. The Font Family list of styles does not appear in the Customizer. I can select normal and (what looks like a fake) bold, but that’s it.

    #581337
    Tom
    Lead Developer
    Lead Developer

    Can you try this instead?:

    add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
    function tu_add_google_fonts( $fonts ) {
    	$fonts[ 'barlow' ] = array( 
    		'name' => 'Barlow',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'barlow_semi_condensed' ] = array( 
    		'name' => 'Barlow Semi Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'barlow_condensed' ] = array( 
    		'name' => 'Barlow Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	
    	return $fonts;
    }

    Let me know πŸ™‚

    #581352
    NBC

    Hi, Tom:

    Yes, that did the trick. I’d love to know why!

    Thanks for the invaluable assistance!

    #581353
    Tom
    Lead Developer
    Lead Developer

    The first instance of the names need to be lowercase and separated by underscores.

    Glad I could help! πŸ™‚

    #581432
    NBC

    Thanks, Tom! I learn something every day.

    #581708
    Tom
    Lead Developer
    Lead Developer
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.