Php WordPress>;使用wp_insert_category()来分隔;类别“名称”;从类别slug或;猫名;
我想使用wp_insert_category()创建一个显示为“My category”但具有“test My category”类别段塞的类别Php WordPress>;使用wp_insert_category()来分隔;类别“名称”;从类别slug或;猫名;,php,wordpress,Php,Wordpress,我想使用wp_insert_category()创建一个显示为“My category”但具有“test My category”类别段塞的类别 我可以用wp_insert_category来做这件事吗?有人举个例子吗?是的,你可以。请执行以下操作: $category = array('cat_name'=>'My Category', 'category_nicename'=>'test-my-category'); wp_insert_category($category);
我可以用wp_insert_category来做这件事吗?有人举个例子吗?是的,你可以。请执行以下操作:
$category = array('cat_name'=>'My Category', 'category_nicename'=>'test-my-category');
wp_insert_category($category);
类别名称用于类别标题,类别名称用于段塞
看
最初的分类法包括:“category”、“post_tag”、“nav_menu”、“link_category”(在wp includes/taxonomy.php中定义)
$parent_term = term_exists( 'fruits', 'product' ); // array is returned if taxonomy is given
$parent_term_id = $parent_term['term_id']; // get numeric term id
wp_insert_term(
'Apple', // the term
'product', // the taxonomy
array(
'description '=> 'A yummy apple.'
'slug' => 'apple'
'parent'=> $parent_term_id
)
);