Skip Navigation

[Resolved] Clarification on meta key and meta value, etc

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 1 reply, has 2 voices.

Last updated by Beda 6 years, 7 months ago.

Author
Posts
#633058

I can see that with ACF:

"ACF is an interface for creating field types. Each field created will appear on a post and allows you to save a value to the wp_postmeta table.

ACF will use the field’s name as the meta_key and the value entered as the meta_value.
Each field in ACF has two entries in the database.

your_field_name contains the value of your field

_your_field_name holds the ACF field key that tells ACF how to find an use the value in the first one."

With Toolset Types, what is the equivalent?

My issue is wrapping my head around the fact that there are two entries for each field in the database.

For example, when it comes to me importing a spreadsheet of data into custom fields I can select either/both fields for a given field to import into. I have been importing into wpcf-fields but now wonder if that is the key for the field itself, and that I am overwriting logic?

#634297

These are WordPress Core features; it is not directly related to either ACF, Types, PODS or any other plugin you will find that plays with post meta.

Let me shed some light on this and share a few lectures.

1. In WordPress you create Posts.
Everything is a post. Pages, Posts and Custom Posts.
They all get stored in the posts table of your database.
https://codex.wordpress.org/Database_Description#Table:_wp_posts

2. There you will find Post Content, Title, Author, Date and much more, but not the information you added to Custom Fields, or post meta as it is called.

3. Custom Fields (also known as post fields, post meta, custom post fields, etc) are all stored in the "postmeta" table:
https://codex.wordpress.org/Database_Description#Table:_wp_postmeta
They will feature four pieces of information, no matter what or where from that field comes:
- meta_id
The ID of the post meta entry, similar to post_id for posts. This is created automatically by when you add a Custom Field.
- post_id
The ID of the post (remember post can be anything, being Custom, Page or whatever else) that this Custom Field belongs to
- meta_key
The slug of your custom field.
When you use Toolset Types, the Custom Field Slug will always be:

wpcf-your_custom_field_slug_here

(Where you replace "your_custom_field_slug_here" with the slug visible when you create the Custom Field in the Types GUI)
As you see we add a prefix. This is to avoid conflicts with other eventual plugins that eventually could register the same field as you do.
- meta_value
This is the actual value that you add to this Custom Field.
It can be anything and depends on the Plugin and type of field.

To import contents - I recommend to read this:
https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/
It leads to some "real life" examples you can use to perform your imports using a Toolset Data structure.

I hope with this you are clear to go!