今天正在尝试使用此功能:
WP Create Categoryhttps://codex.wordpress.org/Function_Reference/wp_create_category
尝试这样做(我还假设它只会将术语添加到内置的“类别”分类法)会引发以下错误:
Fatal error: Call to undefined function wp_create_category() in /yourwebsite/wp-content/themes/fitt/functions.php on line 123
虽然我在/wp-admin/includes/taxonomy中看到了它。php第45行:/**
* Add a new category to the database if it does not already exist.
*
* @since 2.0.0
*
* @param int|string $cat_name
* @param int $parent
* @return int|WP_Error
*/
function wp_create_category( $cat_name, $parent = 0 ) {
if ( $id = category_exists($cat_name, $parent) )
return $id;
return wp_insert_category( array(\'cat_name\' => $cat_name, \'category_parent\' => $parent) );
}
以前有人见过这个吗?一个未定义的函数,尽管它似乎来自代码和Codex文档?