delete_term
will not be working, I am attempting to delete time period and after I deleted it, it’s going to additionally delete the same time period from totally different a taxonomy based mostly on their slugs
this is my code of the delete_term
, so within the code beneath, after I deleted a time period from movies_category
taxonomy, it’s going to look/discover for the same slug
from class
(the default wordpress taxonomy for Posts), after which delete it additionally programmatically, however the code does not work on my finish, I am unsure the place did I am going incorrect right here.
perform delete_similar_term($term_id, $tt_id, $taxonomy, $deleted_term) {
if( $deleted_term->taxonomy === 'movies_category' ) {
$post_cat_term = get_term_by( 'slug', $deleted_term->slug, 'class' );
wp_delete_term( $post_cat_term->term_id, 'class' );
}
}
add_action( 'delete_term', 'delete_similar_term' , 10, 3 );
It is exhausting for me to debug this additionally as a result of I can not see any errors, after I delete a time period from my movies_category
it’ll simply spotlight the time period purple and AJAX delete stops working.