我使用一个特定于站点的插件创建了一个标记为“Richards”的自定义posttype,并使用以下代码。
function add_richards_posttype() {
$labels = array(
\'name\' => _x( \'Richards\', \'Post Type General Name\' ),
\'singular_name\' => _x( \'Richard\', \'Post Type Singular Name\' ),
\'menu_name\' => __( \'Richard\\\'s Dagboek\' ),
\'parent_item_colon\' => __( \'Parent Richard\' ),
\'all_items\' => __( \'Alle Richards\' ),
\'view_item\' => __( \'Bekijk Richards\' ),
\'add_new_item\' => __( \'Nieuwe Richard\' ),
\'add_new\' => __( \'Nieuwe Richard\' ),
\'edit_item\' => __( \'Bewerk Richard\' ),
\'update_item\' => __( \'Update Richard\' ),
\'search_items\' => __( \'Zoek Richard\' ),
\'not_found\' => __( \'Niet Gevonden\' ),
\'not_found_in_trash\' => __( \'Niet Gevonden in Trash\' ),
);
$args = array(
\'label\' => __( \'richards\' ),
\'description\' => __( \'Richard\\\'s Dagboek\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'comments\', \'revisions\' ),
// \'taxonomies\' => array( \'kickstarters\' ),
\'hierarchical\' => false,
\'public\' => false,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
);
register_post_type( \'richards\', $args );
}
add_action( \'init\', \'add_richards_posttype\', 0 );
我已使用添加数据
richards
作为posttype,在数据库中显示正确的posttype。当我想显示此自定义帖子类型的存档页面或单个页面时(通过访问
site.com/richards/
或
site.com/richard/
), WordPress提供404错误页面。
我将public设置为false的原因是为了阻止未登录用户访问此posttype。登录的用户应该能够访问站点。com/richards/未登录时,用户不应。
我搜索这个解决方案已经有一段时间了,我尝试过调整永久链接设置并将其更改回来,添加和删除存档richards。php文件(虽然我希望样式可以依赖于常规的帖子样式),添加和删除菜单按钮?post_type=richards
还有其他一些我记不起来的方法。
我还能尝试什么?我现在该如何着手寻找解决方案?