我购买了这个模板,我正在尝试自定义。
我添加了一个名为location的新分类法类别,并试图用新的分类法类别替换主题中加载的默认类别。
以下是当前代码及其加载类别的位置:
$cats_array = get_categories(\'hide_empty=0\');
$pages_array = get_pages(\'hide_empty=0\');
$site_pages = array();
$site_cats = array();
foreach ($pages_array as $pagg) {
$site_pages[$pagg->ID] = htmlspecialchars($pagg->post_title);
$pages_ids[] = $pagg->ID;
}
foreach ($cats_array as $categs) {
$site_cats[$categs->cat_ID] = $categs->cat_name;
$cats_ids[] = $categs->cat_ID;
}
array( "name" => "Featured Category",
"id" => $shortname."_feat_cat",
"type" => "select",
"options" => $site_cats,
"desc" => "description"),
理想情况下,这种改变应该有效:
$cats_array = get_categories(\'hide_empty=0&taxonomy=location\');
但事实并非如此!很明显,我遗漏了一些东西,不知道如何修复。非常感谢您的帮助。
以下是注册分类部分:
// Register custom taxonomy
register_taxonomy( "location",
array( "woo_estate" ),
array ( "hierarchical" => true,
"label" => "Locations",
\'labels\' => array( \'name\' => __(\'Locations\'),
\'singular_name\' => __(\'Location\'),
\'search_items\' => __(\'Search Real Estate\'),
\'popular_items\' => __(\'Popular Locations\'),
\'all_items\' => __(\'All Locations\'),
\'parent_item\' => __(\'Parent Location\'),
\'parent_item_colon\' => __(\'Parent Location:\'),
\'edit_item\' => __(\'Edit Location\'),
\'update_item\' => __(\'Update Location\'),
\'add_new_item\' => __(\'Add New Location\'),
\'new_item_name\' => __(\'New Location Name\') ),
\'public\' => true,
\'show_ui\' => true,
"rewrite" => true )
);
页面代码也可以在以下位置找到:
http://codepad.viper-7.com/4Wkgg3
http://codepad.viper-7.com/n2hZRI
我最终无法解决这个问题,但我没有使用主题选项文件来动态选择我想要的类别,而是使用了一个覆盖代码来直接(静态)选择我想要的类别,并且成功了。