So, thanks to cjbj I finally found the correct answer! I needed to use edited_term
instead of edit_term
. Very subtle difference. edited_term
fires after a term has been saved.
// insert stuff into description field of taxonomy
function insert_taxonomy_content( $term_id, $tt_id, $taxonomy ){
// only insert content on certain taxonomies
if ( $taxonomy === 'some_custom_taxonomy' ){
// unhook this function so it doesn't loop infinitely
remove_action('edited_term', 'insert_taxonomy_content');
$content = "Some Content";
$update_args = array(
'description' => $content,
);
// update the post, which calls save_post again
wp_update_term( $term_id, $taxonomy, $update_args );
// re-hook this function
add_action('edited_term', 'insert_taxonomy_content');
}
}
add_action('edited_term', 'insert_taxonomy_content', 10, 3);