Support

Account

Home Forums ACF PRO load_field filter on flexible layout

Unread

load_field filter on flexible layout

  • Hello,
    I’m trying to load JS only if a flexible layout is used. But it doesn’t work.
    I tried on the name, the type, and the key, first on the layout then a subfield (and not a group one) but nothing works.
    My code : (tried in functions.php and in a mu-plugin)

    add_action( 'wp_enqueue_scripts', 'sgcc_gmap_scripts', 5 );
    function sgcc_gmap_scripts() {
        wp_register_script( 'sgcc_gmap_section_scripts', 'https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzSampleOneVgUHDuGms7QEqtmUPWIfBU', array(), 'version', true );
    }
    
    add_filter('acf/load_field/name=sgcc_google_map_name', 'load_field_sgcc_section_google_map');
    function load_field_sgcc_section_google_map( $field ) {
        wp_enqueue_script( 'sgcc_gmap_section_scripts' );
        return $field;
    }

    Script is load anytime.

    Is there a method to make it work ?

    Thanks for any answer 🙂

    Loïc

    Edit : Well little embarrassing but… it works with load_value filter. Sorry for the post.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.