Home Forums General Issues What are the postmeta starting with _?


What are the postmeta starting with _?

  • I’m using WordPress with ACF to manage the postmeta. When I look on my database, I found for each postmeta records created by ACF, an input like this :
    meta_key : _example
    meta_value : field_5ea808b820138

    What is this for ?
    What will happen if I delete this input ?
    If I want to insert manually an input “example” in this postmeta table, should I create also a “_example” input ? If yes, what should I put in the meta_value ?

  • This is the ACF field key reference. In your example ‘_example’ tells ACF which field key is used for ‘example’. Without it ACF will not know what type of field it is or allow ACF to format the return value correctly.

    Yes, if you want to insert data manually the field key reference must be inserted. The best way to do this is to use the field key when updating a field that does not already have data in the database update_field('field_5ea808b820138', $value, $post_id);

    For more information see the documentation here

  • Ok thank you, but what does it mean field_5ea808b820138 ? Is this an ID where something is stored on another table ? is that a code ?

  • field_5ea808b820138 is the field key. This is a unique id given to your field by ACF. Fields are stored as posts, that are a custom post type named acf-field. The information about the field is stored in the post table like any other post type. The settings of the field are in the post and meta values related to the post.

  • Ok I saw that, thank you.

    Last question : what will REALLY happen if I can’t add this “_example” input in postmeta ? I will see an error somewhere ? In the admin or in the front pages ?

  • That depends on the field type. You will see problems on the front of the site. For basic fields that store text in the database there will not be a problem. But for a field like a post object field for example, this stores a post ID. ACF will not know what to do with the ID value and will return an integer instead of a post object. Any field that does not store a text value will not work on the front end.

  • Ok, so I guess a field that will store a number will work, correct ?

  • Probably, unless it is a sub field.

    Generally, it’s not a good idea to insert values into the DB without using ACF update_field() using the field key as I mentioned above, or not inserting the field key reference if you’re using some other way to insert the data. Because of the various ways that fields can be added there isn’t any way to predict what might not work. The only way that you can be sure that things will work is if you edit and update every post in the admin after the data is added which likely defeats the purpose of adding it any other way. All import plugins that are ACF aware manage this.

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

The topic ‘What are the postmeta starting with _?’ is closed to new replies.