我会如何在选项面板中的复选框中显示所有网站的类别?在Wordpress选项中用复选框列出类别?
我可以得到一个下拉选择菜单的工作,我只是不知道如何实现复选框。
代码这里从净TUTS:http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/
在此先感谢。
我会如何在选项面板中的复选框中显示所有网站的类别?在Wordpress选项中用复选框列出类别?
我可以得到一个下拉选择菜单的工作,我只是不知道如何实现复选框。
代码这里从净TUTS:http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/
在此先感谢。
嗯,复选框...我可以给你如何显示它们在一个粗略的想法,我没有设法对本教程这样的IM一去不能肯定一切如何组合在一起(我将有另一个今晚对它进行破解)。
我相信你已经有了建立类别的阵列,以及实现复选框的方式很简单:
foreach($categories as $category) {
//print out your checkboxes
echo "<input type='checkbox' name='mychecky' value='$category['whatever value you need']' />";
}
让我知道你上车,我一直意思清理我的WordPress的管理员!
所有最好:)
我想写入类别id到输入值。但它是空白的。我必须为这个问题做些什么?
我的代码:
$categories = get_categories('orderby=name');
$wp_cats = array();
foreach ($categories as $category_list)
{
$wp_cats[$category_list->cat_ID] = $category_list->cat_name;
}
foreach ($wp_cats as $v) {
echo "<input type='checkbox' name='mychecky' value='$category[cat_ID]' />";
echo $v;
echo '<br>';
}
我解决我的问题与此代码块
$categories=get_categories(); foreach($categories as $category) { echo "<input type='checkbox' name='mychecky' value='$category->term_id' />"; echo $category->cat_name;
echo '<br>'; }
可以使用wp_terms_checklist功能(http://codex.wordpress.org/Function_Reference/wp_terms_checklist)