• Hi,

    When accessing API it throws few warning messages.

    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in<b>/Applications/XAMPP/xamppfiles/htdocs/XXXXYYYYZZZZ/wp-content/plugins/wp-rest-api-custom-
    fields/plugin.php</b> on line <b>25</b><br />
    <br />
    <b>Warning</b>:  array_merge(): Argument #2 is not an array in<b>/Applications/XAMPP/xamppfiles/htdocs/XXXXYYYYZZZZ/wp-content/plugins/wp-rest-api-custom-
    fields/plugin.php</b> on line <b>28</b><br />
    <br />
    <b>Warning</b>:  Invalid argument supplied for foreach() in<b>/Applications/XAMPP/xamppfiles/htdocs/XXXXYYYYZZZZ/wp-content/plugins/wp-rest-api-custom-
    fields/plugin.php</b> on line <b>25</b><br />
    <br />
    <b>Warning</b>:  array_merge(): Argument #2 is not an array in<b>/Applications/XAMPP/xamppfiles/htdocs/XXXXYYYYZZZZ/wp-content/plugins/wp-rest-api-custom-
    fields/plugin.php</b> on line <b>28</b><br />

    Can you wrap few lines of code into an IF condition checking is_array( $ACF )?

    
    
    
    if ( is_array( $ACF ) ) {
         foreach( $ACF as $key => &$custom_field ){
             $custom_field = apply_filters( 'JSON_META_' . $key, $custom_field, $_post );
         }
         $_post['meta'] = array_merge( $_post['meta'], $ACF );
    }

    Thanks,
    Dhanendran

  • The topic ‘Throwing few Warnings when accessing API’ is closed to new replies.