cmb2-attached-posts icon indicating copy to clipboard operation
cmb2-attached-posts copied to clipboard

Adding relationship label to attached posts

Open cggit opened this issue 7 years ago • 7 comments

Is it feasible to add relationship labels to the post connections?

Eg. Having a text input field in the attached posts list and storing the text along with the post ID.

cggit avatar Apr 06 '17 20:04 cggit

Not sure I follow. Please elaborate. You should be able to get any data you need using the id that's stored.

jtsternberg avatar Apr 06 '17 20:04 jtsternberg

I'd like to label the relationships between attached posts.

Eg. An actors role in a movie where the actor IDs are stored along with their role in the movie's attached post meta.

The only plugin that I've seen do something similar is the no longer supported Post 2 Post which I believe creates a relationship post type and attaches meta data to it for labels.

cggit avatar Apr 06 '17 21:04 cggit

Ah, I see what you're saying. Yah, that's def. not something this plugin does, and would require some custom coding to make happen.

jtsternberg avatar Apr 06 '17 21:04 jtsternberg

Would you be able to outline in a few words how one could go about integrating this functionality?

I can code but am not very familiar with the CMB2 core. Any guidance is appreciated.

cggit avatar Apr 06 '17 21:04 cggit

I'm afraid it would not be a trivial undertaking and would take more than a few words. Basically, you'd have to add the UI to add the label field, then add the JS or php or whatever to process those fields and make sure they are associated with the ids.

jtsternberg avatar Apr 06 '17 21:04 jtsternberg

Once I have the UI serving relationship labels in $_POST is there a recommended CMB2 hook to add or merge new meta with the existing attached_post meta?

cggit avatar Apr 07 '17 00:04 cggit

I gave it a go and made a pull request. It works but maybe you can suggest improvements.

cggit avatar Apr 08 '17 06:04 cggit