I need to insert several categories (about 400) into my site. The categories are hierarchical.

I would like to load them from functions.php but now I can add one category at time, like this:

add_action('admin_init', 'load_categories');
function load_categories(){
$cat = array(
    'cat_ID' => 0,
    'cat_name' => 'Personale',
    'category_description' => 'La mia categoria',
    'category_nicename' => 'personale',
    'category_parent' => 0,
    'taxonomy' => 'category' 

I would check if category exist and, if not, add it.

My hierarchical structure is like this:

  • category
    • sub-parent-category
      • sub-sub-parent-category

Is this a best practise to load category by functions.php with admin_init action?

I'm sorry but I'm in developer phase at the time and often I clean the database due to tests

1 Answer 1


BlukPress Plugin

Did you try BulkPress Plugin?

Easily add and manage multiple categories, pages, custom taxonomy terms and custom post type posts. Create and reorder terms


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.