我曾使用以下代码列出所有类别:
foreach($categories as $cat) {
print \'<label>\'.$cat->name.\'</label>\';
print \'<input type="text" title="Add value" name="\'.$themename.\'_value_\'.$cat->slug.\'" id="\'.$themename.\'_color_\'.$cat->slug.\'" value="\'.get_option($themename.\'_value_\'.$cat->slug).\'" />\';
}
它为每个类别生成列表和唯一的输入框。
但我用数组重写了结构:
i、 e。
$categories = get_categories(\'hide_empty=0&orderby=name\');
$tz_wp_cats = array();
foreach ($categories as $category_list ) {
$tz_wp_cats[$category_list->cat_ID] = $category_list->cat_name;
}
array_unshift($tz_wp_cats, "Choose a category");
// ==========================//
// Start the theme options! //
// ==========================//
$themename = "Name";
$shortname = "tz";
$options = array (
array( "name" => __("selected", \'framework\'),
"id" => $shortname."_selectedtab",
"std" => "",
"type" => "hidden"),
array( "type" => "opentab"),
array( "type" => "open"),
array( "name" => __("Banner Settings", \'framework\'),
"id" => $shortname."_banner_settings",
"type" => "title"),
array( "name" => __("Show Header Advert", \'framework\'),
"desc" => __("Check this to show a banner in the header of your site (468px x 60px)", \'framework\'),
"id" => $shortname."_banner_header",
"std" => "false",
"type" => "checkbox"),
array( "name" => __("Banner Image URL", \'framework\'),
"desc" => __("Enter the full image URL of your banner (468px x 60px) e.g. http://www.example.com/banner.gif", \'framework\'),
"id" => $shortname."_banner_img_url",
"std" => get_bloginfo(\'template_directory\')."/images/header_advert.jpg",
"type" => "text"),
其结构与上建议的相同
http://blog.themeforest.net/wordpress/create-an-options-page-for-your-wordpress-theme/重写原始方式的解决方案是什么?有什么建议吗?
(我只有一个复选框、文本、文本区域和文件类型)