CMB2-Admin-Extension icon indicating copy to clipboard operation
CMB2-Admin-Extension copied to clipboard

Meta key definition

Open Arifi opened this issue 7 years ago • 3 comments

in one of my projects i used CMB2-Admin-Ext to create a gallery filed. then i wanted to extract those images in a separate single.php file, so i used this code : $images = get_post_meta( $post->ID, '_photos', true); the meta key _photos was foun in the database, it will be good if you add a field in CMB2-Admin-Ext to allow the admin define the meta key because actually i'm spending a lot of time searching how this plugin defines the meta key

Arifi avatar Nov 05 '17 16:11 Arifi

You are right, I have not made this clear. I will add it in the settings and make some documentation.

It takes the field name, converts it to snake case, and prepends it with an underscore and uses that as the key:

Leon Shelhamer > _leon_shelhamer

You can also inspect the field element in the browser to see what is being used for the "name" prop.

cmbr-admin-ext

twoelevenjay avatar Nov 07 '17 14:11 twoelevenjay

As far as adding a field to control the key, I have now displayed the functions to be used to retrieve the metadata. Do you still think it would be useful to have the option to define meta key separately?

edit meta box cmb2 wordpress

twoelevenjay avatar Nov 07 '17 14:11 twoelevenjay

Hi, Sorry i didnt responded earlier.. this is verry nice, at least now we know the key See here how ACF handles fields, you can maybe allow users to define the key name ?

image image

Arifi avatar Dec 24 '17 00:12 Arifi