Sorry I was trying to keep the code simple to post on here. Yes, sorry I understand that the
$value will always be 8. This value eventually be drawn from a mysql query so will show between 1 – 10 depending on the result.
What I have is a custom taxonomy field which I wanted to store the average review score of all the customer reviews related to that taxonomy. So for example if the company’s average score was 8 then it would update my average_review_score field. I can then draw on this value for other parts of the site. This will be updated whenever I call a function that I have written.
In the function it draws the data via a mysql query. From what I understand I then need to use
update_field( $field_key, $value, $post_id ); to update the field. This appears to work because if I execute the following code
$get_av = get_field( "average_review_score", $post_id );
it has changed the value to whatever I enter.
However when I view the Edit Tag in wp-admin its still showing the old value that I originally entered:
I must admit I might have totally misunderstood what I can and cannot do when updating the field. But I basically want to update the value, both in the frontend and backend of the site.
Hopefully this makes it a little clearer as to what I’m trying to accomplish.
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!