所以我创建了一个自定义的帖子类型
add_action(\'init\', \'create_post_type\');
function create_post_type() {
register_post_type(
\'portfolio\',
array(
\'labels\' => array(
\'name\' => \'Portfolio\',
\'add_new_item\' => \'Add New Portfolio Item\',
\'edit_item\' => \'Edit Portfolio Item\'
),
\'public\' => true,
\'capability_type\' => \'post\',
\'supports\' => array(\'title\', \'editor\', \'thumbnail\', \'excerpt\'),
\'menu_position\' => 5
)
);
}
当我添加新的自定义帖子时(http://localhost/wordpress/portfolio/portfolio-item-3/)试着转到那个页面,我得到一个404。怎么了?
UPDATE
This solution 工作,但它做什么,它听起来似乎不好,继续刷新我的重写规则,是吗?
添加
flush_rewrite_rules();
打电话之后
register_post_type
.