Custom Post Type archive giving 404

Question

I am using WAMP with the latest version of WordPress installed. I have a custom post type created using the following…

function register_fruit() {
register_post_type('fruit', array(
'labels' => array(
'name' => __( 'Fruit' ),
),
'public' => true,
'has_archive' => true,
'capability_type' => 'post',
'rewrite' => array("slug" => "/fruit", "with_front" => false),
'supports' => array( 'title', 'editor', 'thumbnail'),
'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
));
}
add_action('init', 'register_fruit', 0 );

This works fine when viewing individual items for example..

www.mydomain.com/fruit/apple
www.mydomain.com/fruit/orange
www.mydomain.com/fruit/pear

But if I try and view the archive pages such as…

www.mydomain.com/fruit

I get a 404, I can’t see where the problem lies, can anyone help?

0
, fightstarr20 7 years 0 Answers 78 views 0

Leave an answer