【发布时间】:2017-05-01 17:05:45
【问题描述】:
我添加了一个具有自己类别的自定义帖子类型。当我想通过菜单导航到分类时,我的整个网站就会崩溃。我在我的自定义分类中对某些类别使用了与我的帖子相同的名称,但我认为这不是问题所在。关于我在这里可能做错了什么的任何想法?
add_action('init', 'ptu_create_post_types');
function ptu_create_post_types() {
register_taxonomy('hotel-taxonomy', 'hotel',
array( 'hierarchical' => true,
'label' => 'Destinations',
'singular_label' => 'Destination',
'rewrite' => array('slug' => 'hotels', 'with_front' => false),
'public' => true,
'show_ui' => true,
'show_tagcloud' => true,
'_builtin' => true,
'show_in_nav_menus' => true));
register_post_type('hotel',
array('labels' => array(
'name' => __('Hotels'),
'singular_name' => __('Hotel'),
'add_new' => __('Add new hotel'),
'edit_item' => __('Edit hotel'),
'new_item' => __('New hotel'),
'view_item' => __('View hotel'),
'search_items' => __('Search hotels'),
'not_found' => __('No hotels found'),
'not_found_in_trash' => __('No hotels found in trash')),
'public' => true,
'supports' => array('title', 'editor', 'post-formats')
));
}
【问题讨论】:
-
还有其他事情发生。我刚刚测试了这个确切的代码,它运行良好。包括使用与普通帖子类别相同的名称和名称作为目的地。您的错误日志中有什么内容吗?
-
我一遍又一遍地测试/调试所有东西,最后发现实际上并不是这段代码被破坏了,而是一个自定义摘录函数由于某种原因卡在了一个while循环中(它只发生在自定义分类法上)。错误日志没有显示任何内容,所以当我弄清楚发生了什么时......
标签: wordpress taxonomy custom-taxonomy