Run Code When You’ve Created/Deleted A CPT-onomy Relationship

Allows you to run code when a CPT-onomy relationship is created or deleted.

Some need-to-knows about actions:

  • To use this action, tweak the code below and add it to your functions.php file.
  • If an action accepts more than one argument, you have to declare the number of arguments in your add_action() declaration, along with the action’s priority.
  • Actions simply allow you to run some code at a specific time. You do not need to return a value.
  • For more information, check out add_action() in the WordPress codex.
<?php
add_action( 'cpt_onomy_created_object_term_relationship', 'my_website_cpt_onomy_created_object_term_relationship', 1, 4 );
function my_website_cpt_onomy_created_object_term_relationship( $term_id, $taxonomy, $object_id, $object_post_type ) {

   // Use the parameters provided to do whatever you want. Go nuts, buddy.
   
}

add_action( 'cpt_onomy_deleted_object_term_relationship', 'my_website_cpt_onomy_deleted_object_term_relationship', 1, 4 );
function my_website_cpt_onomy_deleted_object_term_relationship( $term_id, $taxonomy, $object_id, $object_post_type ) {

   // Use the parameters provided to do whatever you want. Go nuts, buddy.

}
?>