我有个问题$_POST
类别。我得到了这样的东西:
// ADD THE FORM INPUT TO $new_post ARRAY
$new_post = array(
\'post_title\' => $title,
\'post_content\' => $description,
\'post_category\' => array($_POST[\'cat\']), // Usable for custom taxonomies too
\'tags_input\' => array($tags),
\'post_status\' => \'draft\', // Choose: publish, preview, future, draft, etc.
\'post_type\' => \'post\' //\'post\',page\' or use a custom post type if you want to
);
以及关于分类的代码:
<!-- post Category -->
<fieldset class="category">
<label for="cat">Type:</label>
<select name="cat" id="categories">
<?php
$categories = get_categories(\'tab_index=10&taxonomy=category&orderby=name&hide_empty=0&include=6,7,8,9,10\');
foreach ($categories as $category) {
$option = \'<option name ="\'.$category->category_nicename.\'" value="\'.$category->category_nicename.\'">\';
$option .= $category->cat_name;
$option .= \'</option>\';
echo $option;
}
?>
</select>
</fieldset>
但是,如果我使用
wp dropdown categories
这很有效,但我需要
name
用于选项。
wp dropdown categories
不提供名称本身。有没有人知道我错过了什么?
已编辑*
所以,毕竟它是如此简单
<!-- post Category -->
<fieldset class="category">
<label for="cat">Type:</label>
<select name="cat" id="categories">
<?php
$categories = get_categories(\'tab_index=10&taxonomy=category&orderby=name&hide_empty=0&include=6,7,8,9,10\');
foreach ($categories as $category) {
$option = \'<option name ="\'.$category->category_nicename.\'" value="\'.$category->term_id.\'">\';
$option .= $category->cat_name;
$option .= \'</option>\';
echo $option;
}
?>
</select>
</fieldset>