Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter peh4

    (@peh4)

    great to hear that, take care 👍

    Thread Starter peh4

    (@peh4)

    Thank you for your quick answer that motivated me 🙂 this is now working, the last lines caused the error and was useless

    I hope this helps you to add this behavior by default 😉

    add_filter( 'acf/rest/get_fields', function ( $fields, $resource, $http_method ) {
        if ( ! is_array( $fields ) ) {
            return $fields;
        }
    
        // Get our field type by the field name.
        $field_type = acf_get_field_type( 'font-awesome' );
    
        // If our field hasn't been registered and initialized by ACF, do so now.
        if ( ! $field_type instanceof acf_field ) {
    
            // Initialize the class containing our custom field type. If there are any constructor args, you will need to pass those in as well.
            $field = new acf_field_font_awesome([]);
            acf_register_field_type( $field );
        }
    
        return $fields;
    
    }, 10, 3 );
    Thread Starter peh4

    (@peh4)

    I tried to follow this -> https://www.advancedcustomfields.com/resources/integrating-custom-field-types/

    but i don’t know where to paste this (tried in myTheme/functions.php but it crashes)

    
    add_filter( 'acf/rest/get_fields', function ( $fields, $resource, $http_method ) {
        if ( ! is_array( $fields ) ) {
            return $fields;
        }
    
        // Get our field type by the field name.
        $field_type = acf_get_field_type( 'font-awesome' );
    
        // If our field hasn't been registered and initialized by ACF, do so now.
        if ( ! $field_type instanceof acf_field ) {
            // Initialize the class containing our custom field type. If there are any constructor args, you will need to pass those in as well.
            $field = new acf_field_font_awesome();
            acf_register_field_type( $field );
        }
    
        // Get the field array (by the field name) and add it to the array of fields supported by REST.
        $fields[] = acf_get_field( 'font-awesome');
    
        return $fields;
    
    }, 10, 3 );
    
Viewing 3 replies - 1 through 3 (of 3 total)