Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post types called "Emily Davies," "Gemma Patel," and "Poppy Smythe," And I'd like to be access its archives by going to ".../emily_davies" ".../gemma_patel" and ".../poppy_smythe". Emily Davies works, but for some reason the last two don't. They just show 404 error. I have archive-emily_davies.php, archive-gemma_patel.php, abd archive-poppy_smythe.php.

I have this code in my functions.php, and my permalink setting is set to be '/%category%/%postname%/'

add_action( 'init', 'create_post_type' );
function create_post_type(){

register_post_type( 'emily_davies',
array(
'labels' => array(
     'name' => __('Emily Davies'),
     'singular_name' => __('Post'),
     'add_new' => __('Add New'),
     'add_new_item' => __('Add New Post'),
     'edit_item' => __('Edit Post'),
     'new_item' => __('New Post'),
     'all_items' => __('All Posts'),
     'view_item' => __('View Posts'),
     'search_items' => __('Search Posts'),
     'not_found' =>  __('No Posts found'),
     'not_found_in_trash' => __('No Posts found in Trash'), 
     'parent_item_colon' => '',
     'menu_name' => 'Emily Davies'
    ),
'rewrite' => true,
'publicly_queryable' => true,
'public' => true,
'show_ui' => true,
'hierarchical' => false,
'menu_position' => 5,
'query_var' => true,
'has_archive' =>true,
'supports' => array('title','editor','thumbnail','excerpt','comments',)
 )
 ); 
$labels = array(
'name' => _x('Categories', 'taxonomy general name' ),
'singular_name' => _( 'Category'),
'search_items' =>  __( 'Search Category' ),
'popular_items' => __( 'Popular Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Category' ), 
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'separate_items_with_commas' => __( 'Separate Category with commas' ),
'add_or_remove_items' => __( 'Add or remove Categories' ),
'choose_from_most_used' => __( 'Choose from the most used Categories' ),
'menu_name' => __( 'Categories' ),
 ); 
register_taxonomy('emily_category','emily_davies',array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'emily-category' ),
  ));

register_post_type( 'poppy_smythe',
array(
'labels' => array(
     'name' => __('Poppy Smythe'),
     'singular_name' => __('Post'),
     'add_new' => __('Add New'),
     'add_new_item' => __('Add New Post'),
     'edit_item' => __('Edit Post'),
     'new_item' => __('New Post'),
     'all_items' => __('All Posts'),
     'view_item' => __('View Posts'),
     'search_items' => __('Search Posts'),
     'not_found' =>  __('No Posts found'),
     'not_found_in_trash' => __('No Posts found in Trash'), 
     'parent_item_colon' => '',
     'menu_name' => 'Poppy Smythe'
    ),
'rewrite' => true,
'publicly_queryable' => true,
'public' => true,
'show_ui' => true,
'hierarchical' => false,
'menu_position' => 5,
'query_var' => true,
'has_archive' =>true,
'supports' => array('title','editor','thumbnail','excerpt','comments',)
)
 ); 
 $labels = array(
'name' => _x('Categories', 'taxonomy general name' ),
'singular_name' => _( 'Category'),
'search_items' =>  __( 'Search Category' ),
'popular_items' => __( 'Popular Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Category' ), 
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'separate_items_with_commas' => __( 'Separate Category with commas' ),
'add_or_remove_items' => __( 'Add or remove Categories' ),
'choose_from_most_used' => __( 'Choose from the most used Categories' ),
'menu_name' => __( 'Categories' ),
 ); 
 register_taxonomy('popy_category','poppy_smythe',array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'poppy-category' ),
 ));

 register_post_type( 'gemma_patel',
 array(
'labels' => array(
     'name' => __('Gemma Patel'),
     'singular_name' => __('Post'),
     'add_new' => __('Add New'),
     'add_new_item' => __('Add New Post'),
     'edit_item' => __('Edit Post'),
     'new_item' => __('New Post'),
     'all_items' => __('All Posts'),
     'view_item' => __('View Posts'),
     'search_items' => __('Search Posts'),
     'not_found' =>  __('No Posts found'),
     'not_found_in_trash' => __('No Posts found in Trash'), 
     'parent_item_colon' => '',
     'menu_name' => 'Gemma Patel'
    ),
'rewrite' => true,
'publicly_queryable' => true,
'public' => true,
'show_ui' => true,
'hierarchical' => false,
'menu_position' => 5,
'query_var' => true,
'has_archive' =>true,
'supports' => array('title','editor','thumbnail','excerpt','comments',)
)
); 
$labels = array(
'name' => _x('Categories', 'taxonomy general name' ),
'singular_name' => _( 'Category'),
'search_items' =>  __( 'Search Category' ),
'popular_items' => __( 'Popular Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Category' ), 
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'separate_items_with_commas' => __( 'Separate Category with commas' ),
'add_or_remove_items' => __( 'Add or remove Categories' ),
'choose_from_most_used' => __( 'Choose from the most used Categories' ),
'menu_name' => __( 'Categories' ),
); 
 register_taxonomy('gemma_category','gemma_patel',array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'gemma-category' ),
 ));
 }  
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Have you tried refreshing the permalinks?

Visit the permalinks page, and hit save - this SHOULD solve the issue if the CPT's are working properly in every other aspect.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.