Home Forums General Issues ACF Javascript API initial new_field filters not working.


ACF Javascript API initial new_field filters not working.

  • I’m attempting to add some jQuery functionality to all URL fields via the new_field filter in the Javascript API.

    When I add a field through a repeater, things work as expected, however, the fields initially loaded during page load do not have this filter applied.

    Here’s the Javascript code I am using

    (function ($) {
        acf.addAction('new_field/type=url', function($field){
          console.log('URL Field');

    And the PHP for enqueueing.

    add_action('acf/input/admin_enqueue_scripts', function(){
        wp_enqueue_script('sage/acf.js', asset_path('scripts/acf.js'), [], '1.0.1', true);
        wp_enqueue_style( 'sage/acf.css', asset_path( 'styles/acf.css' ), false, '1.0.1' );

    Much thanks for any help you can provide.

  • From your description it appears that the new_field action is only called when a field in added and not when a field already exists. I would try using the ready action.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.