Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta key definition #41

Open
Arifi opened this issue Nov 5, 2017 · 3 comments
Open

Meta key definition #41

Arifi opened this issue Nov 5, 2017 · 3 comments

Comments

@Arifi
Copy link
Contributor

Arifi commented Nov 5, 2017

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 Arifi mentioned this issue Nov 5, 2017
@twoelevenjay
Copy link
Owner

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
Copy link
Owner

twoelevenjay commented Nov 7, 2017

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

@Arifi
Copy link
Contributor Author

Arifi commented Dec 24, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants