使用wp\\u insert\\u category怎么可能引发致命错误?
我按照说明使用它:http://codex.wordpress.org/Function_Reference/wp_insert_category无变化,除非:
$cat_defaults = array(
\'cat_name\' => \'some_name\',
\'category_description\' => \'as asdfasdf sdf adfa fas f\',
\'category_nicename\' => \'\',
\'category_parent\' => \'\',
\'taxonomy\' => \'category\'
);
$someSome = wp_insert_category($cat_defaults);
我不知道它是否相关,但我执行它
add_action( \'init\', array($this, \'registerCustoms\') );
我得到以下错误:
Fatal error: Call to undefined function wp_insert_category() in /home1/stodeckc/public_html/podio-wp-sync/wp-content/plugins/podio_management/libs/appSync/appSync_custom.php on line 61
有什么想法吗?
SO网友:Amit mishra
我认为这里不需要admin\\u init,因为这也定义了分类法。php
因此,请按此方式使用:
require_once(\'wp-load.php\' );
require_once(ABSPATH . \'wp-admin/includes/taxonomy.php\');
$cat_defaults = array(
\'cat_name\' => \'some_name\',
\'category_description\' => \'as asdfasdf sdf adfa fas f\',
\'category_nicename\' => \'\',
\'category_parent\' => \'\',
\'taxonomy\' => \'category\'
);
$someSome = wp_insert_category($cat_defaults);