Roots: Custom Post Type 404 Not Found [duplicate]
-
06-11-2019 - |
質問
This question already has an answer here:
So I'm trying to create a custom post type for my theme. I've written the function to register the post type and I can add a post from the admin panel, but when I try to view the new post's permalink, I get a 404 not found page.
Here's my post type function:
add_action( 'init', 'create_press_coverage' );
function create_press_coverage() {
register_post_type( 'press_coverage',
array(
'labels' => array(
'name' => 'Press Coverages',
'singular_name' => 'Press Coverage',
'add_new' => 'Add New',
'add_new_item' => 'Add New Press Coverage',
'edit' => 'Edit',
'edit_item' => 'Edit Press Coverage',
'new_item' => 'New Press Coverage',
'view' => 'View',
'view_item' => 'View Press Coverage',
'search_items' => 'Search Press Coverage',
'not_found' => 'No Press Coverages found',
'not_found_in_trash' => 'No Press Coverages found in Trash',
'parent' => 'Parent Press Coverage'
),
'public' => true,
'menu_position' => 8,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
'taxonomies' => array( '' ),
'has_archive' => true
)
);
}
I'm using the roots starter theme. Is there some extra configuration I need to do to make custom post types work with it?
Thanks.
正しい解決策はありません
所属していません wordpress.stackexchange