我创建了一个自定义的帖子类型(“公文包”),我可以很好地创建帖子。问题是,当我去查看项目时,它会给我一个404错误。
Here is the portfolio item
这是我注册自定义帖子类型的代码:
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
$labels = array(
\'name\' => __(\'Portfolio\'),
\'singular_name\' => __(\'Portfolio Item\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Add New Portfolio Item\'),
\'edit_item\' => __(\'Edit Portfolio Item\'),
\'new_item\' => __(\'New Portfolio Item\'),
\'view_item\' => __(\'View Portfolio Item\'),
\'search_items\' => __(\'Search Portfolio\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_icon\' => null,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\',\'thumbnail\',\'excerpt\',\'comments\')
);
register_post_type( \'portfolio\' , $args );
}
我错过了一些东西,但我不知道是什么。帮助提前感谢:)