Support

Account

Home Forums General Issues Having issue retrieving field values set programatically

Helping

Having issue retrieving field values set programatically

  • Hello,

    We are using ACF for a site that is getting a lot of the content from an external API. I am calling the API from a cron job and part of that involves setting a field value on one of the custom fields we’ve defined for our custom post type. I see the values in the database, and if I run the import from the wp cli shell, I can retrieve the value with get_field(), but if I restart the shell or try to access the field from a post template via browser, get_field returns false.

    Here is how I set the field in my import script:

    update_field('riverstar_id', '1061', 5994);

    Here is the data in the wp_postmeta table:

    
    |    5994 | riverstar_id               | 1061                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
    |    5994 | _riverstar_id              | field_riverstar_id

    Here is what i get when I call get_field():

    wp> get_field('riverstar_id', 5873)
    => bool(false)

    One thing I noticed is that field field is called “field_riverstar_id” whereas some of my other fields are called “field_588ba5368fd40” or some other random identifier. I don’t know why but this seems significant. “riverstar_id” is definitely defined in the custom field group, I have checked and re-checked it numerous times.

    Any help would be appreciated. Thanks!

    Greg

  • Hi Greg…

    Just checking the relevance of your Post ID in the example above… I see that you are using a different Post ID ( 5994 vs 5873 ) – was that just an oversight, or irrelevant because you are just showing an example?

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

The topic ‘Having issue retrieving field values set programatically’ is closed to new replies.