Last active
January 29, 2019 15:04
-
-
Save michaelwilhelmsen/70749e9c696c7c800b1f5ee3abdcae7b to your computer and use it in GitHub Desktop.
This works even for flexible content fields. Just inspect the field in console when in admin and snab the data-key name from there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_enqueue_scripts', 'sp_register_acf_field_scripts', 5 ); | |
function sp_register_acf_field_scripts() { | |
// Plugin file | |
wp_register_script( 'siema-js', get_stylesheet_directory_uri() . '/bower_components/siema/dist/siema.min.js', array(), '', true ); | |
// Custom functionality | |
wp_register_script( 'siema-init-js', get_stylesheet_directory_uri() . '/library/js/siema-init.js', array(), '', true ); | |
} | |
/* Inspect ACF field in admin to get correct key name */ | |
add_filter('acf/load_field/key=field_5922a0d922cce', 'sp_load_field_assets'); | |
function sp_load_field_assets( $field ) { | |
wp_enqueue_script( 'siema-js' ); | |
wp_enqueue_script( 'siema-init-js' ); | |
return $field; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment