Hi,
I am working with a theme that has embedded taxonomies with custom fields.
Within this custom field there are many values created. My question is, how do I get all the values available, and also, in particular, how do I get the ID for a specific field save that has a specific value?
Thanks
Are you talking about getting the fields that are on the “Related Posts” that are selected? This is covered in the documentation for the relationship field. https://www.advancedcustomfields.com/resources/relationship/
Thanks for the quick response.
To clarify more my doubt, here I attach a dump of my postmeta DB:
When I try to update the POST field=field_5628165af3668 with:
update_field('field_5628165af3668','777',$postid);
It doesn’t add the values on the DB as it does when I select the option in the backend.
What I am doing wrong?
Thanks
A relationship field holds an array of post IDs. In order to add a value you need to first get the existing value and add to it. Example:
$value = get_field('field_5628165af3668', $post_id);
$value[] = '777';
update_field('field_5628165af3668', $value, $post_id);
Thanks John, that did the trick!