EDIT
@kaiser-这个问题与您发布的答案略有不同,我说的是通过单击列标题进行排序,而不是添加下拉列表以按分类术语进行筛选(您将看到我已经在屏幕截图中这样做了)。
正如奥托在回答米洛的问题时所说:“不可能按分类法排序,因为从某种角度来看,这实际上没有多大意义。。。在帖子上使用分类法的目的实际上是在该分类法中包含在帖子之间共享的术语”。
我明白他的意思,因为一篇文章可以附加多个术语,按它们排序是没有意义的。我决定放弃这个想法,如果没有用的话,请随意删除这个帖子。谢谢
ENDEDIT
一直在网上搜寻解决方案,但没有找到我的问题的具体答案。我已经注册了一个自定义帖子类型和两个自定义分类法,但我试图允许管理员按照分类法对帖子进行排序,就像您可以使用日期列一样-请参见此处的屏幕截图:
有人知道怎么做吗?以下是我如何注册自定义帖子类型(如果有任何用处):
Class OSUFestivals
{
public static function init()
{
add_action( "init", array( __CLASS__, "register_directory_cpt" ) );
add_action( "init", array( __CLASS__, "register_workshop_type_taxonomy" ) );
add_action( "init", array( __CLASS__, "register_day_taxonomy" ) );
}
public static function register_directory_cpt()
{
$labels = array(
\'name\' => \'Festival Items\',
\'singular_name\' => \'Festival Item\',
\'menu_name\' => \'Festival\',
\'name_admin_bar\' => \'Festival Item\',
\'add_new\' => \'Add New Item\',
\'add_new_item\' => \'Add New Item\',
\'new_item\' => \'New Item\',
\'edit_item\' => \'Edit Item\',
\'view_item\' => \'View Item\',
\'all_items\' => \'All Items\',
\'search_items\' => \'Search Items\',
\'parent_item_colon\' => \'Parent Items:\',
\'not_found\' => \'No Items found.\',
\'not_found_in_trash\' => \'No Items found in Trash.\',
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'hierarchical\' => false,
\'has_archive\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'author\', \'excerpt\', \'revisions\', \'page-attributes\' ),
\'rewrite\' => array(
\'with_front\' => false,
\'slug\' => \'festival-Items\'
)
);
register_post_type( \'lkfestival\', $args );
}
public static function register_workshop_type_taxonomy()
{
$labels = array(
\'name\' => \'Workshop types\',
\'singular_name\' => \'Workshop type\',
\'search_items\' => \'Search workshop types\',
\'all_items\' => \'All workshop types\',
\'parent_item\' => \'Parent workshop type\',
\'edit_item\' => \'Edit workshop type\',
\'update_item\' => \'Update workshop type\',
\'add_new_item\' => \'Add new workshop type\',
\'new_item_name\' => \'New workshop type\',
\'choose_from_most_used\' => \'Choose from most used workshop types\'
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_admin_column\' => true,
\'rewrite\' => array( \'slug\' => \'event-type\' ),
\'capabilities\' => array (
/* Only let Andrea assign workshop types */
\'manage_terms\' => \'manage_options\', // by default only admin
\'edit_terms\' => \'manage_options\',
\'delete_terms\' => \'manage_options\',
\'assign_terms\' => \'edit_posts\' // means administrator\', \'editor\', \'author\', \'contributor\'
)
);
register_taxonomy( \'lktypes\', \'lkfestival\', $args );
}
public static function register_day_taxonomy()
{
$labels = array(
\'name\' => \'Festival days\',
\'singular_name\' => \'Festival day\',
\'search_items\' => \'Search festival days\',
\'all_items\' => \'All festival days\',
\'parent_item\' => \'Parent festival day\',
\'edit_item\' => \'Edit festival day\',
\'update_item\' => \'Update festival day\',
\'add_new_item\' => \'Add new festival day\',
\'new_item_name\' => \'New festival day\',
\'choose_from_most_used\' => \'Choose from most used festival days\'
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_admin_column\' => true,
\'rewrite\' => array( \'slug\' => \'day\' ),
\'capabilities\' => array (
/* Only let Andrea assign festival days */
\'manage_terms\' => \'manage_options\', // by default only admin
\'edit_terms\' => \'manage_options\',
\'delete_terms\' => \'manage_options\',
\'assign_terms\' => \'edit_posts\' // means administrator\', \'editor\', \'author\', \'contributor\'
)
);
register_taxonomy( \'lkdays\', \'lkfestival\', $args );
}
}
// Load Class
OSUFestivals::init();
我认为“sort”参数
register_taxonomy()
将允许排序,但这似乎与术语添加到对象的顺序有关。