Ok I’m working on a solution. This is what I have so far…This is a multiple way association where when you create/edit a post of a certain CPT-onomy (CPT #1) with associations to particular terms of your other CPT-onomies (CPT #2-infinity), it will update each of the associated terms with a connection back to the post.
For example:
CURRENT POST (CPT #1)
tagged with
CPT #2 TERM #1
CPT #3 TERM #2
CPT #4 TERM #3
Will update:
CPT #2 TERM #1
tagged with
CURRENT POST
CPT #3 TERM #2
tagged with
CURRENT POST
CPT #4 TERM #3
tagged with
CURRENT POST
WHAT IT WILL NOT DO:
1.) If CPT #3 is associated with CPT #2 and your current post is tagged with CPT #3, it will NOT recursively update the current post to be associated with all CPT #2 terms that are associated with the CPT #3 terms selected.
2.) If CPT #2 is hierarchical and TERM #3 belongs to TERM #2 which belongs to TERM #1, tagging the current post with TERM #3 will not connect it to TERM #2 and TERM #1
SOMEONE PLEASE FEEL FREE TO ADD THOSE CAPABILITIES, I’ll work on it more when I can.
function cross_update_CPTonomies($post_id) {
// GET REAL POST ID IF THIS IS A REVISION
if($parent_id = wp_is_post_revision($post_id)){
$post_id = $parent_id;
}
$post_type = get_post_type($post_id);
global $cpt_onomy;
// WHAT CPT-ONOMIES ARE CONNECTED?
$CPTonomies = array({CPT #1 NAME}, {CPT #2 NAME}, {CPT #3 NAME});
// CHECK IF CURRENT POST IS ONE OF THE CONNECTED CPT-ONOMIES
if(in_array($post_type, $CPTonomies)){
// REMOVE THE CURRENT POST TYPE FROM CPT-ONOMIES ARRAY (MEANS YOU CONNECT THE POST TO THE REMAINING CPT-ONOMIES AND NOT TO CURRENT POST TYPE)
// THIS IS OPTIONAL IF YOUR CPT-ONOMIES CONNECT TO THEMSELF
if(($key = array_search($post_type, $CPTonomies)) !== false) {
unset($CPTonomies[$key]);
}
// LOOP THROUGH EACH REMAINING CPT-ONOMY AND CONNECT IT TO CURRENT POST
foreach($CPTonomies AS $CPTonomie){
$terms = get_the_terms($post_id, $CPTonomie);
// CHECK IF POST HAS BEEN ASSOCIATED WITH ANY TERMS OF THIS CPT-ONOMY
if($terms && !is_wp_error($terms)){
// FOR EACH TERM THAT WAS ASSOCIATED, LINK FROM THAT TERM BACK TO CURRENT POST
foreach($terms as $term){
$cpt_onomy->wp_set_object_terms($term->term_id, $post_id, $post_type, true);
} // END FOR EACH TERM
} // END IF POST HAS BEEN ASSOCIATED WITH TERMS OF THIS CPT-ONOMY AND THERE ARE NO ERRORS
} // END FOR EACH REMAINING CPT-ONOMY
} // END IF POST TYPE IS ONE OF THE CONNECT CPT-ONOMIES
} // END CROSS UPDATE CPT-ONOMIES
add_action('save_post', 'cross_update_CPTonomies');