8

So, i have a function in my template file functions.php which cache a search form that contain a custom taxonomie terms. I want to flush cache (or delete one cache group) when I add/delete/edit terms of a specific taxonomie.

Is it possible? maybe with do_action, but for which hook? thx

11

Look at wp-includes/taxonomy.php. The actions are:

do_action( "create_term",       $term_id, $tt_id, $taxonomy );
do_action( "created_term",      $term_id, $tt_id, $taxonomy );
do_action( "edited_term",       $term_id, $tt_id, $taxonomy );
do_action( 'delete_term',       $term,    $tt_id, $taxonomy, $deleted_term );
do_action( "create_$taxonomy",  $term_id, $tt_id );
do_action( "created_$taxonomy", $term_id, $tt_id );
do_action( "edited_$taxonomy",  $term_id, $tt_id );
do_action( "delete_$taxonomy",  $term,    $tt_id, $deleted_term );
8

You are looking for created_term, edited_term and delete_term. Each callback accepts 3 parameters:

function wpse_created_term( $term_id, $tt_id, $taxonomy ) {
}    
function wpse_edited_term( $term_id, $tt_id, $taxonomy ) {
}    
function wpse_delete_term( $term_id, $tt_id, $taxonomy ) {
}    

add_action( 'created_term', 'wpse_created_term', 10, 3 );
add_action( 'edited_term', 'wpse_edited_term', 10, 3 );
add_action( 'delete_term', 'wpse_delete_term', 10, 3 );

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.