So i want to dynamically add terms to a custom taxonomy named after new pages when these are published. Problem I have is that when you edit the page titles, another term will be added to the taxonomy.
This snippet is from this answer, it works for inserting terms.
function add_page_term( $post_ID ) {
$post = get_post( $post_ID );
wp_insert_term( $post->post_title, 'mypages' );
}
add_action( 'publish_page', 'add_page_term' );
So far I tried to first get the post_ID and then replace it with the post_title using the pre_insert_term hook or to override the value with str_replace but had no success. Any ideas on this? Help is highly appreciated. Thanks in advance!