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
Hi André,
I have WP REST API, WP REST API Custom Fields and Advanced Custom Fields installed, but the custom fields I have set up are not showing in the JSON. Do I need to add or alter code somewhere? You claim “This plugin works straight out of the box.” ??
Kind regards
]]>