0

Is it possible to add a link category on plugin activation?

What I mean is the Links section, as you know by default it has the Blogroll link category. I want to add a new link category when my plugin is activated, is there a quick and easy way to do this? What is the best method to use?

Thanks.

3

Link category is a simple taxonomy just like categories , named: link_category so to add one you can use wp_insert_term() eg:

wp_insert_term(
  'My link category', // the term 
  'link_category', // the taxonomy
  array(
    'description'=> 'this is a description.',
    'slug' => 'my-link-category'
  )
);

and to make all this happen on plugin activation take a look at register_activation_hook

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.