So I created a custom post type like
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
)
);
}
When I add a new custom post (http://localhost/wordpress/portfolio/portfolio-item-3/) and try going to that page, I get a 404. Whats wrong?
UPDATE
This solution works but what does it do and it sounds like its not good to keep flushing my rewrite rules isit?
Add
flush_rewrite_rules();
after you call
register_post_type
.