我正在尝试设置自定义帖子类型" staff"在WordPress中(过去我在其他网站上做了很多次),但是当我尝试在WordPress仪表板中查看自定义帖子类型的edit.php列表时,列表中显示的帖子就是那些使用内置的帖子类型" post,"而不是发布类型"员工。"
换句话说,[MyWordPressSite] /wp-admin/edit.php?post_type=staff会显示post_type =' post'的帖子,而不是帖子有post_type =' staff&# 39 ;. All和Published旁边括号中的数字是post_type =' staff'的正确数量。帖子,但显然不符合列出的帖子。
这是我用于register_post_type的代码:
add_action( 'init', 'staff_init' );
function staff_init() {
$labels = array(
'name' => 'Staff' ,
'singular_name' => 'Staff Member' ,
'menu_name' => 'Staff' ,
'name_admin_bar' => 'Staff' ,
'add_new' => 'Add New Staff' ,
'add_new_item' => 'Add New Staff Member' ,
'new_item' => 'New Staff Member' ,
'edit_item' => 'Edit Staff Member' ,
'view_item' => 'View Staff Member' ,
'all_items' => 'All Staff Members' ,
'search_items' => 'Search Staff Members' ,
'not_found' => 'No staff members found.' ,
'not_found_in_trash' => 'No staff members found in trash.'
);
$args = array(
'labels' => $labels,
'description' => 'Staff Members' ,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' )
);
register_post_type( 'staff', $args );
}
我已经尝试禁用网站上的每个插件,运行flush_rewrite_rules()
(多次),并将帖子类型的名称更改为1000%确定无法在任何地方使用否则,但似乎没有任何帮助。
答案 0 :(得分:2)
问题解决了。在我的functions.php深处,有一个函数使用set_query_var
将post_type
变量重置为'post'
(这样工作人员就不会被包含在存档页面中),但没有进行is_admin()
测试。