Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have simple code:

add_action('init', 'categoryTransfer');

function categoryTransfer(){
//some code
    for($i=0; $i < count($categories); $i++)

But when it executes i get:

Fatal error: Call to undefined function wp_create_category() in /Users/noname/Sites/wp-content/plugins/my_plugin/my_plugin.php on line 95

Where is a problem?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This function is declared in wp-admin/includes/taxonomy.php.
This file will be loaded in wp-admin/includes/admin.php.
And that now is called in wp-admin/admin.php.

So the solution is: Use the hook 'admin_init' or require all necessary files manually. But don’t do that on every request.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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