delete category on plugin deactivation wordpress
You should save that category id in option table instead of set as global. Try below code which is helps you to delete that category on deactivation hook. function add_category_on_activation(){ $wpdocs_cat = array(‘cat_name’ => ‘Event Category’, ‘category_description’ => ‘An Event Category to show all events’, ‘category_nicename’ => ‘events’, ‘category_parent’ => ”); $wpdocs_cat_id = wp_insert_category($wpdocs_cat); if($wpdocs_cat_id) … Read more