已创建自定义帖子类型-无法查看

时间:2013-09-09 作者:Tara

我创建了一个自定义的帖子类型(“公文包”),我可以很好地创建帖子。问题是,当我去查看项目时,它会给我一个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 );      
}
我错过了一些东西,但我不知道是什么。帮助提前感谢:)

2 个回复
最合适的回答,由SO网友:hariprasad 整理而成

做以下事情并尝试。

刷新重写规则。(检查链接enter link description here).

SO网友:Arda Basoglu

尝试重新生成永久链接。

转到Settings / Permalinks 然后单击Save 按钮

结束

相关推荐