1

I need to create a hook after the creation, edit and deletion of a taxonomy organizing a custom post type I have. I've noticed though that I can't use the following actions with those taxonomies:

add_action( 'create_category', 'some_function' );
add_action( 'delete_category', 'some_function' );
add_action( 'edit_category', 'some_function' );

It would be ideal if I could use these because I only really need the ID of the category to do the process I had in mind. Is there some argument I can pass in with register_taxonomy() that will allow those actions to be associated with taxonomies of custom post types? Or is there some way to simulate these hooks in another way?

Any help is greatly appreciated.

1

What you're looking for are the create_$taxonomy, edit_$taxonomy and delete_$taxonomy hooks. $taxonomy is, of course, your taxonomy name.

<?php
add_action( 'create_your_tax', 'wpse32510_create', 10, 2 );
funciton wpse32510_create( $term_id, $tt_id )
{
   // do stuff
}

There's also create_term, edit_term and delete_term.

Best place to find hooks: http://adambrown.info/p/wp_hooks/

  • This works fine, but is there a way that the action can fire when adding an associated custom post type to it via the post's edit screen? Sort of like how when you add a Post to a Category it fires the edit action. This currently doesn't happen for some reason. – jimlamiell Nov 1 '11 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.