Home Forums Backend Issues (wp-admin) Getting the values from a custom field


Getting the values from a custom field

  • Hi,
    I am working with a theme that has embedded taxonomies with custom fields.

    Custom Field

    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?


  • 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.

  • 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:


    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?


  • 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!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.