Home › Forums › ACF PRO › Getting data from JSON – ACF Plugin › Reply To: Getting data from JSON – ACF Plugin
function acf_json_ipm($json_acf_url_field, $acf_radio_field) {
//Make a request
$json_request =
wp_remote_get('https://jsonplaceholder.typicode.com/photos/1');
if( is_wp_error( $json_request ) ) {
return false; // Bail early
}
// Get JSON and Decode
$json_body = wp_remote_retrieve_body( $json_request );
$json_data = json_decode( $json_body );
// Import values from JSON
$values = array (
'field_619788e2cde63' =>$json_data,
'field_61978bfe4a2c2' =>$json_data,
'field_61978c0898706' =>$json_data,
'field_61978c4c98707' =>$json_data,
'field_61a8c63bea0c0' =>$json_data,
);
//Update Group field and save1
update_field('acf_group_field_key', $values);
I am trying to populate some ACF-fields as you can see above with data coming from a JSON.
I used your code because it makes alot of sense to me.
Is this a correct rewrite? Should i create a new thread?.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.