0

Want to call a function after my custom taxonomy was deleted. But the hook is not getting fired.

Registered taxonomy on init hook callback

    register_taxonomy(
        'college-session',
        'collegesession',
        array(
            'label' => __( 'College Session','college-session' ),
            'rewrite' => array( 'slug' => 'college-session' ),
            'hierarchical' => false,
        )
    );

The hook is listed in WP hook reference page.

deleted_$taxonomy

Runs after a term in a specific taxonomy is deleted, and after the term cache has been cleaned.

Is this a known issue.? Does anyone have a solution/example.?

add_action('deleted_college-session', 'update_deleted_session_relations');

function update_deleted_session_relations($tt_id){

    // Do the action here

}
  • What's your code for registering the taxonomy? And what's the action you're trying to perform? – Jacob Peattie Feb 7 at 13:28
  • @JacobPeattie Question updated – mujuonly Feb 8 at 5:47
  • I don't think that's a valid action, try delete_$taxonomy. – Milo Feb 8 at 6:23
  • @Milo deleted_term_taxonomy (Since version 2.9.0) Runs after a term taxonomy ID is deleted. – mujuonly Feb 8 at 6:30
  • I can't see any problem with your code so far, so the question is what makes you think the hook isn't running? What code are you attempting to run on the hook? – Jacob Peattie Feb 8 at 6:35

Your Answer

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

Browse other questions tagged or ask your own question.