insert category
-
Hello everyone, I am developing a plugin and I want to give some defaults categories within my custom taxonomy. I want the user to be able to delete/edit these defaults if they’d like so unless I’m wrong (very possible), I need to add these categories when my plugin gets activated and this is where I am running into problems. Take the following code.
function bbradley_rfp_activation() { $my_cat = array('cat_name' => 'My Category', 'category_description' => 'A Cool Category', 'category_nicename' => 'category-slug', 'taxonomy' => 'Services'); // Create the category $bbt = wp_insert_category($my_cat); mail($myemail, 'sub', $bbt); } //add_action("admin_init", 'bbradley_rfp_activation'); register_activation_hook( __FILE__, 'bbradley_rfp_activation');
When I try to insert the category on the activation of my plugin, it doesn’t work. But if I do it using the admin_init hook, it works but then it can’t be deleted since it would be added every time they visit the admin page. Can someone tell me what I’m doing wrong?
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘insert category’ is closed to new replies.