CMB2-Admin-Extension
CMB2-Admin-Extension copied to clipboard
Meta key definition
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
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.
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?
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 ?