I've been learning Wordpress for the last few days but I'm having an issue with custom post types.
I've registered the post type as below:
function create_kitchen_type() {
$kitchen_args = array(
'labels' => array(
'name' => __( 'Kitchens' ),
'singular_name' => __( 'Kitchens' )
),
'public' => true,
'has_archive' => true,
'description' => 'Kitchen custom post type description',
'supports' => array(
'title',
'editor',
'comments'
),
'taxonomies' => array('category'),
'rewrite' => array(
'pages' => false
)
);
register_post_type( 'kitchen_post', $kitchen_args );
};
add_action( 'init', 'create_kitchen_type' );
In index.php the post types (currently just one) are outputted like so:
$custom_post_args = array(
'_builtin' => false,
'public' => true
);
$post_types = get_post_types( $custom_post_args, 'objects' );
foreach ( $post_types as $post_type ) {
echo '<a href="' . $post_type->name . '">' . $post_type->labels->singular_name . '</a>';
};
// Outputs: <a href="kitchen_post">Kitchens</a>
Then, when the link is clicked, the address bar displays localhost/site_name/kitchen_post
but the title is "Page not found | ", and the single echo that I've added to archive-kitchen_post.php is not displayed.
So, why isn't archive-kitchen_post.php used?
Thanks in advance.