• Note – I am using the ACF field in theme options – if not being used in options then you can use the normal get_field( ‘your_field_name’) without the –>> , ‘ option’
    To see the Array printed in a Human friendly view:

    <?php
    echo '<pre>'.print_r(get_field( 'your_field_name', 'option'), true).'</pre>';
    ?>

    To see the entire array:

    <?php 
        $google_1 = get_field( 'your_field_name', 'option' );
        var_dump($google_1);
    ?>

    IN USE:
    place at the top of your page or call from somewhere

    <?php
        $google_1 = get_field( 'your_field_name', 'option');
        //Inner Arrays
        $vars = $google_1['variants'];
        //Not necessary in the US because latin is the Google default
        $subs = $google_1['subsets'];
        // Get all array items - comma separated
        $vars_string = rtrim(implode(',', $vars), ',');
        $subs_string = rtrim(implode(',', $subs), ',');
    ?>

    CALL OUT:

    <style>
    @import url('https://fonts.googleapis.com/css?family=<?php echo $google_1['font'] ?>:<?php echo $vars_string ?>&display=swap&subset=<?php echo $subs_string ?>');
    </style>

    OR
    <link href="https://fonts.googleapis.com/css?family=<?php echo $google_1['font'] ?>:<?php echo $vars_string ?>&display=swap&subset=<?php echo $subs_string ?>" rel="stylesheet">

    I hope that helps someone
    Cheers

    • This topic was modified 5 years, 1 month ago by tbsworks.
  • The topic ‘Some Examples – Documentation’ is closed to new replies.