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

Reciprocal Relationships?

Open forwardtrends opened this issue 7 years ago • 4 comments

Is there a way to use the relationship both ways (reciprocal)?

For instance lets say I have 2 CPTs - cars and car parts.

So when editing a car, you can drag the part or parts to attach them.

When editing a part, is there a way I can see and manage all the cars that are already attached to it?

I can write a function to do this - just looking for a shortcut if it's already built in somehow. Thanks

forwardtrends avatar Apr 03 '18 15:04 forwardtrends

It is not currently a thing, but is something I've been planning to do/document for ages. Did you build something?

jtsternberg avatar Apr 26 '18 13:04 jtsternberg

Just on the front end by querying postmeta for the related post IDs

$rows = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE (meta_key= 'yourkey_attached_parts' ANDmeta_value LIKE '%".$current_post_id."%')");

forwardtrends avatar Apr 30 '18 11:04 forwardtrends

This would be a fantastic feature to have. +1

edvind avatar Jun 18 '18 14:06 edvind

This seems to maybe be a duplicate of https://github.com/CMB2/cmb2-attached-posts/issues/28, or at least relate

tnorthcutt avatar Dec 26 '18 16:12 tnorthcutt